A well formed web page is one that adheres to the latest W3C validation specification, and can pass the W3C Markup Validation Service. This simply means the HTML code has been correctly written, and does not make any claims about how good the web page is in any other respects.
Once your page has been created you should run it through the validator check at the W3C website. To check the validation of this page please click the W3C buttons at the bottom of this page.
There are also several required elements that must be included within the HTML code for the page to be validated correctly. To be validated correctly all pages must contain the correct Doctype or Document Type Definition, for the type of HTML you will be using. The Doctype is not actually an HTML tag, but rather is a set of specifications that tells the browser which version of the markup language it should use to display the page. The Doctype must be the first element on the page, above the opening HTML tag. If you omit the Doctype not only will your page fail to validate, but other elements such as style sheets will not behave correctly. Your page may still display correctly in certain browsers, as they are designed to be forgiving of formatting errors. However the search engines will often take longer to index badly formatted HTML.
This site, and all new web sites designed by littledetails.co.uk, use the XHTML 1.0 Transitional Doctype, which can be seen by viewing the source code on this page. The remaining discussion on this page will focus just on this particular Doctype, along with the UTF-8 character encoding also used on this page, and not HTML 4.0 or earlier. We believe this gives the best compromise of validity and functionality compared to the other Doctypes available. We choose not to use the XHTML Strict Doctype as this does not allow links to open in a new window using the target attribute.
There are two other elements required in the head area of your page to be validated as XHTML 1.0 Transitional, an XMLNS declaration in the opening HTML tag, and the character encoding. Rather than go in to a lengthy discussion about these elements, please just view the source code and view the first few lines of code in this page, up to the title tag.
All HTML code and tags must be written and lower case and should be correctly nested to XML standards. Every opening tag must be closed, and the correct reverse order maintained for the closing tags. This means the last tag to be opened must be the first closed. For example if you write a paragraph in bold and italic you must nest the tags as follows:
<p><strong><em>A bold and
In the case of single tags, such as form text inputs, images and line breaks, the tag must still be closed. This is done by placing a space and then the closing forward slash at the end of the tag as follows:
<img src="image.gif" alt="my image" height="10" width="10" />
Some tags have required attributes, such as the image alt tags, and therefore must always be used as shown above. Attributes cannot be minimised by simply naming the attribute, for example when a radio button is pre-selected you must write out the full attribute and quote enclosed value such as:
Certain characters such as ampersands and pound signs do not conform to the basic character encoding used, and therefore you must use their HTML character value instead.
Pound (£) = £
Ampersand (&) = &
Copyright (©) = ©
Pages which are well formed are faster and easier for search engines to index. Tests have shown that when otherwise identical web pages are created and submitted to Google, the pages which validate correctly are the first pages to show within the Google search results. If your pages do not validate, they will be indexed eventually, although you may not achieve the same ranking.
Additionally, well formed web pages can be viewed on a wider range of devices, and different browsers. Without the correct Doctype and character encoding, your HTML and CSS will operate in the browsers fall-back mode, and any problems you try to resolve in displaying the code may be more related to the implementation by the browsers, and you may find you have to correct the mistakes of one browser by writing separate style sheets. Therefore setting the correct standards at the start will save time throughout the project. Once you get in the habit of creating web pages correctly, well formed internet pages take exactly the same amount time to create as badly formatted pages.