Well the other day Steve made the mistake of reminding me of the existence of the W3C Markup Validator. I think the gist of the conversation involved complaining about it, but the fact that my code wasn’t W3C compliant got on my nerves. So in between compiling LFS 6.2 and BLFS 6.1, I took a night off to learn what parts of my code weren’t being W3C compliant and fix them.

I didn’t get it all done that night, but I did learn a few things. Now tonight, I am proud to announce that fugitivethought’s front page is completely W3C standard compliant. And if they aren’t picky, I don’t know who is!!

A few quick tips for anyone who wants to use the validator to check out their site:

  • If you’re using PHP, be sure that the top line of the PHP file that loads is <? header(“Content-type: text/html; charset=utf-8”); ?> – this informs the browser what type of text format to expect the PHP output to be in. Of course if you are using a different character set, change the utf-8 to whatever it is, but chances are it’s probably utf-8
  • The most recent version of HTML, which seems to be what I’ve been writing in anyway, is HTML 4.01. So right after the header for the text encoding, include the line: <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”&gt; which tells the browser to expect 4.01 code. I used transitional because I still like such tags as <center> and <font>. Somewhere down the road I’ll break down and convert it all over to 4.01 Strict. But if you put transitional in the DOCTYPE, at least the browser knows what to expect.
  • Be sure to close all tags in the proper place. For instance, W3C doesn’t like unordered lists to be embedded inside paragraph tags. So whenever you are using an unordered list, end the paragraph tag, start the unordered list, end the unordered list, end the paragraph tag. This is true for a lot of other types of tags too.
  • USE THE SHOW SOURCE CHECKBOX! – Especially if you are working on PHP code. This helps immensely because it shows you the code as it sees it and includes the line numbers it references!

Alright, I hope this blog post doesn’t break the W3C compliancy, because that would just make me mad……