As it's common to write , , and together on the same page, it is very important to have a solid grasp of one language before the next is introduced. The general rules for utilizing all of these languages together are:

    Content that is static, unchanging and different for each page is written in HTML.

    Any content or interactivity that needs to be both dynamic and dependable is written in PHP, such as include() and date().

    Appearance and “light” interactivity is written in CSS.

    “Heavy” interactivity that needs to respond quickly but which may be considered optional is written in JavaScript.

    PHP, being interpreted by the server, is executed first; the result is then sent to the client, which reads the completed page from the top down.

These rules reflect the client-server relationship discussed earlier: server-side languages are slower but highly dependable; client side languages are quicker, but we have have few ways of knowing if they were interpreted correctly or not. Features that are absolutely required to work every time therefore tend to be written in a server-side language; features that are optional are client-side. This also tends to CSS: the user could, in theory, see your page with CSS turned off, and it should still be readable.

Note that these are not absolute rules: there is increasing fuzziness towards the edges of each language. For example, JavaScript can interact with a server via AJAX, and CSS can increasingly be used to do what was only possible in JavaScript. But they suffice as general rules.

Enjoy this piece? I invite you to follow me at to learn more.