English see: http://dflying.dflying.net/1/archive/98_web_standard_and_aspnet__part1_xhtml_quick_start.html
Web standards have become increasingly popular, and websites that comply with web standards are also becoming the trend of web development. ASP. NET is also a very popular technology in Web development. In this series, I hope to share with you some ideas on using ASP. NET 2.0 to build websites that comply with web standards.
Refer:
Http://www.w3.org/MarkUp/
Http://www.w3.org/TR/xhtml1/
Http://msdn.microsoft.com/asp.net/reference/infrastructure/default.aspx? Pull =/library/en-US/dnaspp/html/aspnetusstan. asp
This is the first article in this series. We will introduce some basic XHTML concepts and the significant differences between traditional HTML and XHTML. In order to make HTML developers targeted and get started quickly.
The popular HTML markup language has been officially recognized as obsolete and will take over of it as XHTML (http://www.w3.org/MarkUp ). If your website is written according to strict XHTML rules, the website will be consistent in different browsers. In addition, you can think that the consistency of the website appearance will still be ensured in the future browser version upgrade and change. You will also receive consistent support across browsers, devices, and platforms.
XHTML has the following two main objectives:
- Separate the structure (using the XHTML Markup Language) and representation (using CSS) of the document
- Write HTML as an XML
For the first target, W3C deletes some HTML tags and attributes, such as <font> and bgcolor, because these tags or attributes are not part of the document structure, it is only used to describe how a document should be displayed. Therefore, it should be defined in a CSS file rather than in HTML. Similarly, some specific TAG content does not have to be displayed as specific. For example, the font size displayed in the
For the second goal, XHTML strictly complies with the strict Syntax of XML. It can be said that XHTML is the result of HTML reconstruction according to XML syntax. In other words, when you write an XHTML document, you are actually writing a special XML document. XML documents have more strict syntax than HTML, which will be discussed later in this article.
XHTML has three versions:
- XHTML 1.0 transitional
- XHTML 1.0 strict
- XHTML 1.0 frameset
XHTML 1.0 transitional contains all the tags and attributes of html4.01. It is not so strict as to make it easier for existing HTML developers to accept and use XHTML.
XHTML 1.0 strict is the strict version of XHTML. Developers must strictly abide by the rules for separating the structure and performance of documents. That is to say, they must use CSS to control the display of pages instead of using <font>, bgcolor.
XHTML 1.0 frameset is used to split a document into Several partitions to display different contents. (XHTML 1.0 transitional and strict pages cannot contain<Frameset>Mark ).
I will not describe more about XHTML here. If you are interested, you can use Google or MSN Search to find a lot of related information or details. You are also welcome to leave your comments and questions in this post, so that we can discuss them together. The following are some basic rules for writing XHTML.
An XHTML page must be a well-organized and legal XML document. The fourth part of XHTML 1.0 Recommendation describes several differences between HTML and XHTML. The most important of the Force column is the following 10:
- The page must contain a valid XHTML doctype.
A valid XHTML page must contain the XHTML doctype definition before other content appears. When you create a new ASP. NET page in Visual Studio 2005 or Microsoft Visual Web Developer. A valid XHTML 1.0 transitional doctype has been automatically added to the page. The following are four standard XHTML doctype:
XHTML 1.0 transitional
1 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
XHTML 1.0 strict
1 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML 1.0 frameset
1 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 frameset // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XHTML 1, 1.1
1 <! Doctype HTML public "-// W3C // dtd xhtml 1.1 // en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Different XHTML doctype will also determine how the browser will display specific content, which will be discussed in several articles in the future.
- The root node of the page must specify the XHTML namespace.
<HTML> A default namespace must be specified for the tag. For example, An XHTML 1.0 transitional page should have the following declaration:
1 <HTML xmlns = "http://www.w3.org/1999/xhtml" XML: lang = "en" lang = "en">
- All tags and attribute names must be lowercase letters.
XML syntax is case sensitive, so<Div>And<Div>Are Different tags. Of course, only <div> is a valid XHTML tag.
- Attribute values must be enclosed in a pair of quotation marks.
Quotation marks can be double quotation marks or single quotation marks. The following statement is invalid:
1 <a href = page. aspx> link </a>
The quotation marks surrounding page. aspx are missing and should be written as follows:
1 <a href = "Page. aspx"> link </a>
Visual Studio 2005 and visual web developer can automatically enclose attribute values in quotation marks. This function can be set in tools, options, and format.
- All non-null tags must appear in pairs.
That is to say, the separate <p> or <br> are invalid and the corresponding closure mark is required.
Note the commonly used <br> mark. The line feed that meets the XHTML syntax should be <br> </BR> or abbreviated as <br/>, however, in some browsers, the <br> </BR> label in <br> </BR> is regarded as a misspelled <br> label and is corrected as another <br>, in this way, two line breaks are generated. To avoid unnecessary troubles, we recommend that you write it as <br/>. Note that some browsers cannot recognize <br/> (note that there is no space before '/'), so do not forget to add a space before.
- Tags cannot overlap.
Tags can be nested, but they cannot overlap. The following statement is legal:
1 <B> <I> This is bold and italic </I> </B>
The following statement containing overlapping statements is invalid:
1 <I> <B> This is bold and italic </I> </B>
- Attribute cannot be abbreviated.
All attributes must be specified. For example, a common Writing Method
1 <input type = "checkbox" checked/>
It is invalid in XHTML because there is no value corresponding to the checked attribute. It should be rewritten
1 <input type = "checkbox" Checked = "checked"/>
- Use the ID attribute instead of the name attribute.
In HTML, the name attribute can be used to identify<A>,<Applet>,<Form>,<Frame>,<IFRAME>,<IMG>And<Map>Mark. XHTML 1.0 strict and XHTML 1.1 standards have deleted the support for the name attribute. We should use ID to uniquely identify the elements on a page.
- Processing of spaces in attribute values.
All spaces at the beginning and end of the attribute value are ignored. Multiple spaces or linefeeds between words in the attribute values are considered as single spaces. For example, the values of the following two attributes are the same: <input value = "HTML is out"/>
<Input value = "HTML is
Out "/>
- The content marked by <SCRIPT> and <style> must be enclosed in the CDATA segment.
For example:
1 <SCRIPT type = "text/JavaScript">
2 <! [CDATA [
3 function func (A, B)
4 {
5 if (a <B)
6 RETURN true;
7}
8]>
9 </SCRIPT>
Note that the above script contains a less than sign (<). If it is not enclosed in the CDATA segment, the less than sign (<) and the subsequent content will be mistakenly considered as the start of another XHTML mark, cause unnecessary errors.
It should be noted that IE considers the CDATA segment in the <SCRIPT> flag to be invalid and may cause a script error. This problem can be avoided by using JavaScript Annotations:
1 <SCRIPT type = "text/JavaScript">
2/** // * <! [CDATA [*/
3 function func (A, B)
4 {
5 if (a <B)
6 RETURN true;
7}
8/** // *]> */
9 </SCRIPT>
Or
1 <SCRIPT type = "text/JavaScript">
2 // <! [CDATA [
3 function func (A, B)
4 {
5 if (a <B)
6 RETURN true;
7}
8 //]>
9 </SCRIPT>
Of course, the best way is to place scripts and CSS in a separate file and add references to the XHTML page.
To be continued ......