Validating HTML5 in the browser

I like to be alerted of any validation errors that sneak into my markup as soon as possible. That’s why I find the HTML Validator Extension for Firefox very hard to live (well, work) without.

Unfortunately, it does not support HTML5. I’ve been looking hard for an alternative that does and has the same features as the HTML Validator Extension, i.e. runs locally in the browser without sending anything to a remote server and validates every page you load automatically.

No luck.

There are tools that validate markup by sending it to a remote server, either automatically or manually, but I don’t want that. I want to be able to check my work even though it’s behind a login or if I’m not connected to the Internet.

If you happen to know of a browser extension that solves this problem, please let me know. It doesn’t have to be for Firefox – Opera, Chrome or Safari would be fine too as long as it runs on my Mac.

Be careful with non-ascii characters in URLs

One thing that is rather common, especially on websites whose content is not in English, is URLs that contain unencoded characters such as space, å, ä, or ö. While this works most of the time it can cause problems.

Looking at RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax, characters that are allowed to be used unencoded in URLs are either reserved or unreserved. The unreserved characters are a-z, A-Z, 0-9, -, ., _, and ~. The reserved characters are used as delimiters and are :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, and =.

In essence this means that the only characters you can reliably use for the actual name parts of a URL are a-z, A-Z, 0-9, -, ., _, and ~. Any other characters need to be Percent encoded.

So what does using an unencoded character like space or å in a URL mean in practice?

  • It doesn’t work in all user agents. Recent browsers seem to handle it pretty well, but older browsers may not be able to follow links or load images. It also causes problems for some other software that expects URIs to be valid (Ruby’s URI.parse is one).
  • It may make URLs ugly and hard to read since browsers may percent encode some of these characters before displaying them in the location bar. This varies from browser to browser. A URL like http://example.com/å ä ö/ may be displayed as http://example.com/å ä ö/, http://example.com/å%20ä%20ö/, http://example.com/%C3%A5%20%C3%A4%20%C3%B6/, or even http://example.com/√•%20√§%20√∂/.

To keep things simple and predictable, consider sticking to the unreserved characters in URLs unless you have a really strong internationalisation requirement for using other characters.

Remember non-vendor-prefixed CSS 3 properties (and put them last)

Everybody wants to use CSS 3 now that even Internet Explorer will support parts of it once IE 9 is out. But since parts of CSS 3 are still subject to change, most browsers use a vendor prefix for many CSS 3 properties to signal that their implemenation is “experimental” and may change in a later version of the browser.

This means that for a property like border-radius to work cross-browser you need to specify it several times with different vendor prefixes, like this:

.box {
  -moz-border-radius:10px;
  -webkit-border-radius:10px;
  border-radius:10px;
}

The -moz- prefix targets Firefox and other Gecko-based browsers, -webkit- is for older versions of Safari and other WebKit-based browsers, and the non-prefixed border-radius property is currently used by Safari 5, Chrome, Opera 10.5, and IE 9.

“Inspect element” is not the same as “View source”

Tools like Firebug for Firefox, WebKit’s Web Inspector and Opera’s Dragonfly are indispensible tools for front-end Web developers, letting you view the DOM as the browser sees it.

And that’s where these tools can actually cause some problems, or at least a bit of confusion. When you choose “Inspect element” or otherwise bring up one your browser’s DOM inspector, what you’re looking at is the document tree after the browser has applied its error correction and after any JavaScripts have manipulated the DOM. It is not necessarily the same as what you see when you choose “View source”.

CSS Colors: Take Control Using PHP


While many web sites use powerful programming environments to create HTML, these same tools are usually ignored when it comes to creating Cascading Style Sheets (CSS). This article describes how to take control of your colors in CSS using PHP. You will learn how to:

  • Centralize your color definitions using variables.
  • Separate presentation and content by referring to colors using abstract names such as base and highlight.
  • Automatically generate a color gradient from a single base color:
    -5
    -4
    -3
    -2
    -1
    0
    +1
    +2
    +3
    +4
    +5
  • Automatically adjust the contrast of foreground colors so they can viewed on top of your background colors:
    -5
    -4
    -3
    -2
    -1
    0
    +1
    +2
    +3
    +4
    +5

Learn CSS Positioning in Ten Steps

his tutorial examines the different layout properties available in CSS: position:static, position:relative, position:absolute, and float

1. position:static

The default positioning for all elements is position:static, which means the element is not positioned and occurs where it normally would in the document.

Simple 2 column CSS layout

This is a tutorial on how to use CSS to create a simple two column layout.


The layout consists of a header, a horizontal navigation bar, a main content column, a sidebar, and a footer. It is also horizontally centered in the browser window. A pretty basic layout, and not at all difficult to create with CSS once you know how to deal with the inevitable Internet Explorer bugs.


To see the full CSS used for each step, view source on the example documents.