HTML and CSS Reference
In-Depth Information
Decision Making: Are Standards Necessary?
Browsers are very forgiving of lapses in syntax. In fact, this is one of the reasons that non-
programmers were able to quickly create their own Web pages in the early days of the World
Wide Web. Part of the conflict between XHTML 2.0 and HTML5 was over whether it was crucial
to future Web development to enforce syntax rules in the next generation of Web sites. It was a
debate that HTML5, with its support for flexibility in enforcing syntax rules, decisively won.
In light of this, you may wonder if it's really important to validate a document and follow
syntax rules when browsers are so accommodating. In fact, there are several good reasons
to enforce syntax rules and follow good coding practices:
• Although many browsers accommodate variations in syntax, not all browsers do so and
not always in the same way. However, when you follow the syntax rules of the W3C, all
browsers enforce those rules and in the same way.
• Web pages tend to be rendered more quickly when they use good syntax because brows-
ers don't have to interpret poorly written code.
• If a browser renders one of your pages incorrectly, it's easier to debug the page if it's
written in compliance with standard syntax. Many Web developers do a validation check
as part of the debugging process to locate errors in the code.
• In a working group where several people are tasked with maintaining the same Web site
code, you need to have a common set of rules to avoid confusion and mistakes. Why not
use the rules set down by the W3C?
• Even if you are writing a page in HTML5, your business might also need to create XML-
based documents. Given the similarity between the two markup languages, it's easier for
everyone to use the same set of syntax rules.
Even if you're writing your code in HTML5, it's best to follow the syntax rules of XHTML.
This does not mean you have to run a validation check every time or add a namespace or
an XML prolog; but you should use XHTML standards such as lowercasing element and
attribute names, and always provide attribute values enclosed within quotes.
Session 9.2 Quick Check
1. An XHTML transitional validation test reports the following error:
Line 51, column 3 : tag for “br” omitted, but OMittAG nO was specified
ƒƒƒƒƒƒ<br >
Suggest a possible cause of the error and how you would correct it.
2. A validation test under XHTML 1.0 strict reports the following error:
Line 59, column 12 : there is no attribute “align”
<pƒ a lign=”left”>
Suggest a possible cause of the error and how you would correct it.
3. A validation test under XHTML 1.0 strict reports the following error:
Line 22, column 14 : there is no attribute “name”
<formƒ n ame=”orders”>
Suggest a possible cause of the error and how you would correct it.
4. Suggest how to write code for a hypertext link to open in a new browser window
and still be valid under the XHTML strict DTD.
5. What is the difference between PCDATA and CDATA?
6. Why would you want to place an embedded style sheet within a CDATA section?
Search WWH ::




Custom Search