HTML and CSS Reference
In-Depth Information
The position of each of the elements within your code is important. Make sure that both the start and end tags of
your element are nested within the same element. For example, you should never have a start tag within the
<body> element and the end tag outside of it. This code would be invalid, but more importantly, it will sometimes
cause your web page to be displayed incorrectly in a web browser.
Indenting elements that are nested within others (as you have done with the <p> elements in your web page) is
useful to quickly identify the structure of your HTML code.
Validating Your Web Page
Validating your web pages allows you to be sure that your code is standards-compliant . This means that the code
that you write follows the best practices and guidelines outlined in the relevant web standards.
Why Should You Validate?
Although validation is not mandatory, it is an important part of the development process. You should validate your
code for a number of reasons:
Debugging your code —Validation can be a useful way to find errors in your code that may be causing
problems with how a page is being displayed in web browsers. For example, it is easy to miss an end tag in
your code, resulting in problems with how browsers show the layout of the page. Using a validator can help
you to find where end tags are missing or incorrectly placed, saving you a lot of time going painstakingly
through each line of your code to check that you have used tags correctly.
Future-proofing your code —Just because your code works in browsers today does not mean that it will
work in the future. Browser makers generally implement technologies as they are defined in the relevant
specifications, and these specifications are designed to ensure that technologies will be backwards compat-
ible with older versions. This means that if you follow the web standards today, your code is more likely to
work in the future because browser makers have a better idea of how your code is structured and what it is
trying to do.
What Are Web Standards?
Web standards are specifications developed by organizations such as the W3C (World Wide Web Consortium) and
WHATWG (Web Hypertext Application Technology Working Group)—developers sure like their acronyms! These
specifications outline how browser makers should implement new technologies in their browsers and how deve-
lopers should use these technologies.
The actual specifications are often very long and fairly dull to read. Luckily, however, there are concise versions of
the HTML5 specification available for developers that cut out the more boring stuff aimed at browser makers. You
can find the WHATWG web developer version of the HTML5 spec at and
the W3C version at .
Just to make things a little more confusing, the W3C and WHATWG both maintain separate versions of the HTML5
specification. These are mainly identical, but I have found that the WHATWG tends to adopt new technologies
more quickly than the W3C does.
Search WWH ::

Custom Search