XHTML goals, rules and details

Source: Internet
Author: User
Tags format cdata closing tag empty html page lowercase net dreamweaver
Xhtml  

Two purposes:
1, the content of the page and form clearly separate
2, making page content closer to XML

Why to achieve these two goals, a lot of places are speaking, but, here is simple to say two
1, and why asp.net to be layered is a reason, after the separation of content and form, an XHTML-compliant page can be repeated design without changing the content of the page
2, the reason for proximity to XML, which is a lot of places to talk about, most importantly, HTML can be interpreted by IE, but his too loose form, a large number of form tags, does not help to express semantics, in a word, HTML is used to render, but it has forgotten the importance of data, data not only to be presented, but also the best easy to understand , which is precisely the strength of XML, which is used to represent data

The version standard for XHTML is three
XHTML 1.0 Transition Edition, this is more relaxed
XHTML 1.0 Strict Edition, strict requirements form and content separation
XHTML 1.0 Framework Edition, added support for frameset

What are the standards that XHTML 1.0 contains? or what page is the XHTML1.0 spec page?

1, the beginning of the page must contain a correct XML DOCTYPE declaration
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
Or
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
This note, this statement is to tell the browser how to render the page, want to do a test, you do two pages in the Dreamweaver, one in HTML, one with XHTML standard, content is a 100%-width 100%-high table, you give the table to apply the border, in IE view, You will find that the HTML standard, the table is indeed 100% high 100% wide, but the XHTML will not, the table height can not reach 100% high, which means that IE in rendering, will be based on the DOCTYPE declaration of the Difference

2, the root element must indicate the XHTML namespace
HTML is usually the http://www.w3.org/1999/xhtml">
3, all element and attribute names to lowercase
4, the property value must be enclosed in double quotes
This one is easy for many people to forget, because in HTML, numeric attribute values, we often do not write double quotes, like the A-tag href, you can not write
However, VS. NET options, there are options to let vs.net automatically help you generate property values in double quotes, and can automatically change the case, it is very convenient
5, each element must have a closing tag, and if it is an empty element, write by the XML rule, that is, to write
6, Mark do not cross, this should be no problem, but, ie no matter you do not intersect, its fault-tolerant ability is very strong (not error correction OH)
7, the attribute must have a value, before we write checkbox properties, always write <input type= "checkbox" checked> this time, must be written <input type= "checkbox" checked= "true "/>
8, with the id attribute instead of the name attribute, it is logical, after all, id more popular, especially in the server side technology, and DHTML, there are many related to the ID of the method, really do not know what to do with the name (not referring to the input class Oh, refers to a,img, etc.)
The contents of 9,<script> and <style> tags must be used
<! [cdata[
]]> Surround
This is also easy to understand, otherwise, if you <SCRIPT> in the <> form of characters, will be the browser as XHTML markup to render, but, you should not think that is directly with the above tags, you want to include, ie must be an error, Because IE although know them, but JavaScript when they are code ah, how to do? The right thing to do is to add JavaScript annotations
/*<! [cdata[*/
/*]]>*/
This will do, however, I just started to see the above method, very skeptical, because of this, ie how to resolve/**/it? The original said, "The CDATA section are hidden from the JavaScript, the but isn't from the" browse R that parses the page, which means that although JavaScript comments it out and ignores it, the browser still parses it
Of course, the better way is to put the script and style in an external file.

The other part is my advice.
1, the abolition of some old tags, such as font,b,i,u, and so on, is basically those used to decorate the format of the tag
2, as far as possible use DIV to layout rather than table, of course, if you do not know, with a table can also, but, or slowly cooked good, as for the reason, I think, div at least in the use of the Robert program to crawl more than the table better resolution
3, with style to control the layout and format of the page, try not to use content style, to ask why, you think, inline style reuse rate is low, and too dispersed
4, choose a good XHTML editor
A good editor can help you write XHTML standard pages with less effort
Vs. NET HTML Designer has not always been very good, and vs.net2003 does not provide XHTML support at all, it only supports labeling automatic lowercase, automatically double quotes for attributes, does not support automatic overwrite of empty tags, and does not support the validation of conformance to XHTML
It is recommended here that you use Macromedia DREAMWEAVER MX 8, which is indeed the best HTML Designer in the world, and it supports 100% of XHTML features, from creation to validation, especially validation, which allows you to verify that there are violations of XHTML rules after you create them.

Some details
DOCTYPE switch
Different DOCTYPE declarations are not the same for browsers as they are in rendering processing, mainly like box calculation rules.
This is something many people don't know, for example, IE6 supports two modes, one is Standard mode, the other is loose mode, if it is XHTML, it will be handled in standard mode, if it is normal HTML page, it is treated with loose mode, so, a page with the same content, DOCTYPE not the same, out of the details there are some differences

This article translates and abstracts a document published on MSDN by Stephen Walther, see http://msdn.microsoft.com/asp.net/reference/design/default.aspx? Pull=/library/en-us/dnaspp/html/aspnetusstan.asp



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.