Validation: the Key to Longevity
Monday, December 8th, 2008 | web site development
There is a lot to a web site that the usual visitor doesn’t see. This doesn’t mean however that what’s going on behind the curtain isn’t important. We’ll talk more later about designing for multiple browsers later (all browsers are NOT created equal), but there are some things you can do to make sure you’re at least writing code appropriate for multiple browsers. This is called validation. There are a fair number of rules, so in the end run your web site through a tool like Total Validator to learn what doesn’t validate with your code.
Some does or don’ts:
- target=”_blank” is out, rel=”external” is in. Here’s the javascript that makes it work:
<script type="text/javascript"> // External Links function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; } } window.onload = externalLinks; </script> - do not use in-inline styles, use a CSS file. For instance: <img src=”mypic.jpg” border=”0″ /> is out. Instead, either create a img tag CSS style that says border:none or create a class that does the same and change the above to <img src=”mypic.jpg” class=”noborder” /> — “noborder” could be changed to whatever you want.
- <img src=”mypic.jpg”> is out, <img src=”mypic.jpg” /> is in. Properly close those tags! Same with <br> tags. Should be <br />
Want to learn more about validation? Learn what the W3C has to say about it. Or you can entrust your web site and it’s valid code to Seattle web design firm Noodle Design >