Web Standards, XHTML, and CSS
"The best day of your life is the one on which you decide your life is your own. No apologies or excuses. No one to lean on, rely on, or blame. The gift is yours - it is an amazing journey - and you alone are responsible for the quality of it. This is the day your life really begins." - Bob Moawad
A website that complies with web standards refers to a site that has valid or nearly valid HTML, CSS and JavaScript. In other words, the code follows a set of standardized best practices for building web sites. Following these “web standards” is important to SEO because search engine spiders love clean comprehensive code. These standards play even a more important role in affecting accessibility and usability of a website. The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web and they are constantly working on developing standards.
XHTML, or Extensible HyperText Markup Language, is a markup language that has the same depth of expression as HTML, but also conforms to XML syntax. XHTML is a reformulation of HTML in XML and valid XHTML can be automatically processed using standard XML tools (unlike HTML). This language has been added to W3C recommendation list. So why use XHTML instead of HTML? You don’t have to but it could be beneficial! Most people that use XHTML today use it because it allows you to deliver web content to many devices (like phones) that cannot support HTML syntax. This can bring more traffic to your website and you save time and problems in creating custom XML. In reality, however, many of these devices today are quickly adding HTML support. Others use XHTML because it’s “the future” and it has to be well-formed so if it validates you have really clean code. However, there are also arguments against using XHTML.
As I mentioned before, XHTML is well-formed and it carries requirements from XML. This means that all element and attribute names are case-sensitive, tag names need to be lowercase, all attribute values must be enclosed by quotes, and all elements must be explicitly closed, including empty elements. There are many other requirements which make it more difficult to add certain objects to a website, like some DHTML or Flash content, without getting errors from validation. However, if your page validates, you have clean code that search engines can quickly understand. Thus, weather you choose to use HTML or XHTML, remember to write clean code and validate.
How do you validated a website document? First, before you validate, make sure to included the correct DOCTYPE in your code! A DOCTYPE, or document type declaration, tells the browser which Document Type Definition (DTD) the document conforms to and thus, tells the browser validator which version of (x)html you are using. A Document Type Declaration should be placed at the top of every page before the root element. Your markup and css will not validate without it. Most importantly, DOCTYPES are essential to have your website render and function properly across browsers. So what DOCTYPE should you use? If your code is done in HTML you will need a different DOCTYPE than XHTML so it depends on your code but take a look at Valid DTD List to make your decision. When you set the DOCTYPE properly use the W3C’s Markup Validator to validate your website.
CSS, or Cascading Style Sheets, is a stylesheet language used to describe the presentation of a document written in a markup language. It is used to style web pages written in HTML and XHTML, but it can be used with any kind of XML document. The CSS specifications are maintained by the World Wide Web Consortium (W3C). CSS has a simple syntax that consists of a list of rules that define colors, fonts, layout, and other aspects of document presentation. The purpose of CSS is to separate document content from document presentation which gives a website more flexibility and control. It also improves accessibility and reduces complexity and repetition in the structural content. Thus, same markup page can be presented in different styles for different rendering methods. For example, you can create an alternate stylesheet for “print view” where content stays the same but it’s presented differently with CSS and more appropriately for printing. Overall, you should use CSS!
Tags: validation, w3c