A good first step is to understand what the different languages are used for, so you can pick and choose which to use for your purpose. Some are interchangeable, so are not. By that I mean that some have similar purposes/uses and some have totally different purposes/uses.
The first division of languages to understand is that some languages are client side and some are server side. The 'client' is the web browser (Internet Explorer, Firefox, Opera, etc). Client side languages are sent by the web server to the web browser and executed in the web browser. Examples of client-based languages are HTML, XHTML, CSS, Javascript, XML. The 'server' is the web server. The web server sends data to the web browser to be displayed. You don't have to use a server side language. If you want to use only client side languages, then the web pages will be defined as files on the web server and the web server (Apache, IIS, etc) simply sends the files to the client on request. But server side languages can be run on the web server to generate the web pages that are sent to the client. For example, if you want to display a web page that contains all the names in a database of employees, you will use a server side language that will 1) connect to the database, 2) execute a query to retrieve the names from the database, 3) loop thru the database results, generating the HTML/XHTML/XML to display the names and (you don't explicitly do this) send the generated HTML/XHTML/XML to the client.
HTML (Hyper Text Markup Language): A language for defining a web page. HTML commands define the page structure and objects. Web page objects are things like input fields (input box, select dropdowns, radio buttons, check boxes, list boxes), content control objects (table, div, paragraph). HTML also includes commands/attributes for controlling the 'look' of a web page. These commands/attributes can control things like font, font size, font color, background of the page or an object, height, width, and position on the page.
XHTML (Extensible HTML): XHTML is a modernized version of HTML. The main changes are that XHTML conforms to XML syntax and the 'look' commands are removed from the language and have to be controlled using CSS. Moving from HTML to XHTML is not too hard. It means getting used to some slightly different syntax and using more CSS to control the 'look' of the page. XHTML is used to define the content of the page, ie. what text and images are on the page and how they are group.
CSS (Cascading Style Sheets): CSS is used to define how a web page looks. CSS is used to define the color, size, font and positioning of things on a web page. A well designed webpage, with good CSS, can be made to look totally different, simply by switching which between two CSS files. The 'content' of the page would be the same, but by changing the colors, positioning, sizes via CSS, that exact same content can look very, very different. CSS can also be used to make things visible or not visible.
HTML, XHTML, and CSS are non-procedural languages. They do not have 'if' or looping statements or variables to hold data. Coding strictly with non-procedural languages is analogous to building in concrete. Once you put something somewhere, it's going to stay there. There is no way to move/change it. Procedural languages have 'if' statements and loop statements that allow your code to make decisions and do different things based upon the data involved. For example, if the variable 'foodItem' contains 'ice cream', then display a list of ice cream flavors.
NOTE: From this point on, the term HTML means both HTML or XHTML.
Javascript: Javascript is the procedural language that is run in the client. The Javascript code is sent to the web browser along with the HTML. The execution of Javascript code can be triggered by various methods: during the page load, after the page load completes, the user pushing a button or link, by a mouseover, when a field accept focus, etc. The use of Javascript in a web page, changes the 'concrete' to 'jello'. Now you can move things around and change things. Using Javascript with CSS can make things move or appear/disappear on the page.
XML (Extensible Markup Language): XML is language mainly used to define data. It can be used to define data and data files that can be transferred without regard to the operating system (PC, Apple, Linux, your car's GPS). Modern browsers can display XML files without any type of HTML. But the page is pretty static.
For the most part, you chose between HTML or XHTML (or even XML) as the language to define the web page content. Additionally, you can choose to use Javascript for control in the client, and/or CSS for controlling the look of the web page.
PHP: A language that can be run on the web server as part of the web server engine (Apache, IIS?). A PHP web file can be a mostly HTML file with bits of PHP code interspersed. The web server recognizes the PHP and executes it before the file is sent to the client. Normally, the PHP code generates some HTML/CSS/Javascript that becomes part of the HTML that is sent to the client. For example, you can have an entire page defined with HTML, that has tiny piece of PHP code that displays the current date at the top of the page. Before sending the web page to the client, the web server scans the file for PHP code. In this example, it executes the PHP code, which generates some text and possible HTML to display the current date. This modified HTML is then sent to the client. By the time the HTML gets to the client, you can't tell which parts where original HTML and which parts where generated via PHP. The other extreme is that a PHP web file can be mostly PHP code that generates HTML/CSS/Javascript to send to the client. Whether a PHP web file is mostly HTML or mostly PHP or any mix in between, the web server executes any PHP code and then sends the remaining/generated HTML/CSS/Javascript to the client. PHP allows a web page builder to have procedural language constructs (if, looping, variables, database access) while building the web page. PHP can be installed on the web server as part of the web server engine, and it can be installed as a non-web related programming language on a computer. PHP can be installed on Windows, Linux and Apple computers.
Perl: Perl is pretty much the same type of language as PHP. I believe that Perl is older. At this point I don't have a good description of the differences between Perl and PHP. I believe that PHP is easier to use for web pages. I believe that is because PHP was developed specifically for use with the web server. But, anything said in the paragraph above about PHP, is also true about Perl.
JSP: JSP is the method for embedding Java into web page files. The combination of Java/JSP is much like PHP and Perl, in that the language can be used without a web server or through the web server. There are many flavors of Java that are web related. At this point I don't have the knowledge to do more than mention them. Besides Java and JSP, I've heard of Java Beans and Structs. I believe that Beans are simply Java programs that can be called from a JSP page to perform tasks.
When a web file is written in a language such that the whole program generates HTML etc to send to the web client, I consider that a CGI program. CGI programs are non-HTML programs that can be called as a web page from a web client. The CGI program generates as output, a bunch of HTML/CSS/Javascript that is sent back to the client. Basically, they are programs that 'print' a bunch of HTML to 'stdout', and 'stdout' is redirected to go to the client. This (most likely) simplified definition of CGI allows PHP, Perl and Java to be considered CGI languages.
C/C++: C and C++ (I assume C#?) can also be used as a CGI language. Again, CGI is simply a program that can be called by a web client and outputs HTML/CSS/Javascript that is sent back to the client.
SQL: SQL is a language for accessing a database. It is not specifically a web related language, but many web pages use database access, so I've included it here. Each database has is specific version of SQL. Mysql, Informix, Oracle, DBII, SQL Server, etc. all use a version of SQL. The basics of each 'flavor' of SQL is similar, but there can be differences. A large part of SQL is the same between flavors.
I'm pretty sure that this is not an exhaustive list of server side languages. These are simply the ones that I have had experience with.
For the most part, you chose one of these server side languages to use for a given web page. I don't believe that you can mix them in on page. Exceptions may be that a page in one language may be able to call a subprogram in written in another language. If that is possible, it's probably a little detailed to get it to work correctly. For example, I believe that a JSP web page can probably call a program written in C/C++. But that would be done mainly if there is a task that C/C++ is much better suited for than Java.
Comments: until I add a comment form, you can email comments, questions, constructive critism to 'tmp@arnett.name'.