Grow your CSS skills. Land your dream job.

#11: Working Modularly with PHP

Many sites do not use any fancy Content Management System (CMS) to generate their pages, they are just just good ol' static HTML content. A site for your grandmothers pie baking business probably only has a few pages, perhaps a homepage, about page, and contact page. Each of these pages has different main content, but much of it stays exactly the same, like the header, navigation, and footer. Think of these sections as "modules" that you can easily use PHP to insert into the page. This way, making changes to those sections changes all the pages at the same time, saving you time and potentially mistakes. At the end, I show you how you can still achieve unique effects in your navigation despite the code being identical.


  1. Eduardo
    Permalink to comment#

    Isn’t is better to use ‘if-else’ instead of that ultra-complex css?

    Love your tutorials ;)

  2. Permalink to comment#

    Fantastic tutorial Chris! A new breakthrough in the way I think about designing websites!

  3. Tom
    Permalink to comment#

    Thanks for the great tutorials! I just used this one on my website…

  4. Ryan
    Permalink to comment#

    Yes you can tell (at 6:10 of the video) that the html code was inserted via php. The way you indent and space your code is unique and you wouldn’t make a simple html indentation mistake like that had it been in an html file and not included using php. A way to fix that, depending on how your organizing your code, would be to use the same spacing as you would a normal html file. So your paragraph tag would a have a couple tab indentations in the header.html file, but your heading tag is fine because php includes the file right where you put the php include statement with the spacing.
    I hope this makes sense. I’m enjoying your screencasts very much! Keep it up Chris.

  5. is no longer available for download from the itunes podcast could be reviewed, Greetings

Leave a Comment

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like ```this```. You don't need to escape code in backticks, Markdown does that for you.

Sadly, it's kind of broken. WordPress only accepts a subset of HTML in comments, which makes sense, because certainly some HTML can't be allowed, like <script> tags. But this stripping happens before the comment is processed by Markdown (via Jetpack). It seems to me that would be reversed, because after Markdown processes code in backticks, it's escaped, thus safe. If you think you can fix this issue, get in touch!

If you need to make sure the code (typically HTML) you post absolutely posts correctly, escape it and put it within <pre><code> tags.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".