XHTML Specification Definition: Label names and attributes are case sensitive.
More rules for XHTML syntax:
- Property names must be lowercase
- Attribute values must be quoted
- Attribute cannot be abbreviated
- Replace the name attribute with the Id attribute
- XHTML DTD defines the HTML elements that are forced to use
Property names must be lowercaseThis is wrong:
WIDTH
= "100%" >
That's right:
width
= "100%" >
Attribute values must be quotedThis is wrong:
<table width= 100%
>
That's right:
<table width= "100%"
>
Attribute cannot be abbreviatedThis is wrong:
<input checked><input readonly><input disabled><option selected><frame noresize>
That's right:
<input checked= "Checked"/><input readonly= "readonly"/><input disabled= "disabled"/><option Selected= "selected"/><frame noresize= "noresize"/>
Here is a list of abbreviated attributes for HTML, as well as overrides in XHTML:
HTML |
XHTML |
Compact |
compact= "Compact" |
Checked |
Checked= "Checked" |
Declare |
Declare= "DECLARE" |
ReadOnly |
readonly= "ReadOnly" |
Disabled |
disabled= "Disabled" |
Selected |
Selected= "Selected" |
Defer |
Defer= "Defer" |
Ismap |
ismap= "Ismap" |
Nohref |
nohref= "Nohref" |
NoShade |
Noshade= "NoShade" |
NoWrap |
nowrap= "NoWrap" |
Multiple |
Multiple= "multiple" |
Noresize |
Noresize= "Noresize" |
Replace the name attribute with the id attributeHTML 4.01 defines the name attribute for the following elements: A, applet, frame, iframe, IMG, and map.
The use of the name attribute in XHTML is discouraged and should be replaced with an ID.
This is wrong:
name
= "Picture1"/>
That's right:
id
= "Picture1"/>
Important Compatibility Tips:You should add an extra space before the "/" symbol to make your XHTML compatible with today's browsers.
Language attribute (lang)The lang attribute is applied to almost all XHTML elements. It defines the type of language used within the content of the element.
If you use the lang attribute in an element, you must add additional Xml:lang, like this:
lang="no" xml:lang="no"
>heia norge!</div>
Forced use of XHTML elementsAll XHTML documents must have a file type declaration (DOCTYPE declaration). The HTML, head, body elements must exist in the XHTML document, and the title element must be in the head element.
The following is a minimized XHTML file template:
<!DOCTYPE Doctype goes here>
Tip: File type declarations are not part of the XHTML document itself. It is not an XHTML element, nor does it close the tag.
Tip: The xmlns attribute within the,
XHTML defines three types of file-type declarations. The most common use is XHTML transitional. <! Doctype> is mandatory for use.There are three main parts to an XHTML document:
The basic document structure is this:
<! DOCTYPE ... >
In an XHTML document, the document type declaration is always on the first line.
An example of XHTMLThis is a simple (minimized) XHTML document:
<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >< Html>
Document type declaration defines the type of document:
<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
The remainder of the document resembles HTML:
3 Types of document declarations
- The DTD specifies the syntax for Web pages that use Universal Markup Language (SGML).
- Generic markup languages such as HTML should use DTDs to prescribe rules that apply to tags in a particular document, including a series of elements and entity declarations.
- In the document type declaration or DTD of Universal Markup Language (SGML), XHTML is described in detail.
- The XHTML DTD uses an exact language that can be read by the computer to describe the syntactic and syntactic syntax of a legitimate XHTML tag.
There are three types of XHTML documents:
- STRICT (Strict type)
- Transitional (Transition type)
- FRAMESET (frame type)
Three types of XML documents for XHTML 1.0XHTML 1.0 Specifies three types of XML documents to correspond to the three DTDs described above.
XHTML 1.0 Strict<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 strict//en" "http://www.w3.org/TR/xhtml1/DTD/" xhtml1-strict.dtd
>
Use in this case: clean markings are required to avoid confusion in the presentation. Use in conjunction with cascading style sheets.
XHTML 1.0 Transitional<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/" xhtml1-transitional.dtd
>
Use in this case: when you need to take advantage of HTML performance features, and when you need to write XHTML for browsers that do not support cascading style sheets.
XHTML 1.0 Frameset<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 frameset//en" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-frameset.dtd"
>
Use in this case: when the browser window needs to be split into two or more frames using the HTML framework.
How do I upgrade your site to XHTML?In order to convert a site from HTML to XHTML, you should first familiarize yourself with the XHTML syntax rules explained in the previous chapters.
The following steps are described below.
Add a file type declarationAdd the following file type declaration to the first line of each page:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Note: This site (W3school) uses a strict DTD. Using a transitional DTD is a good choice, however, because a strict DTD may seem "too restrictive" for most developers who get started.
A hint about the file type declarationIf you want to validate the page as the correct XHTML, the page must contain a file type declaration.
It is important to note that, depending on the file type declaration, the new browser handles the document differently. If the browser reads a file type declaration, it will process the document in a "proper" manner. If there is no DOCTYPE, the document may be displayed in a different way.
lowercase label and attribute namesBecause XHTML is case sensitive, and because XHTML accepts only lowercase HTML tags and attribute names, you can perform a simple search and replace command to change all uppercase labels to lowercase. Do the same with attribute names. We have been using lowercase letters on our own website, so basically, the Replace feature is not too much to use.
Enclose all attributes in quotation marksSince the XHTML 1.0 standard requires all attribute values to be quoted, if you have not noticed this detail before, you will need to check the Web site page by line. This is a time-consuming task, so never forget to quote the attribute value again.
Empty tags:Empty tags are not allowed in XHTML.
This creates a new problem that Netscape will misread <br/> tag. We don't know why, but it's no problem to change it to <br/>. With this in mind, you'll need to make changes to the label again through the search and replace feature.
Other tags, such as the tag, may also encounter the same problem. Do not use closed tabs to close , but to add/> at the end of the label.
Verify siteAfter all this, use the link below to validate all modified pages according to the official web site DTD: XHTML Validator. Next, there may be a small number of errors that are found, each of which is corrected (manually). Our experience is that the most likely mistake is to omit the </li> tag from the list.
Should we use a conversion tool (say TIDY)? Yes, we could have used TIDY.
Dave Raggett's HTML Tidy is a free tool for cleaning up HTML code. TIDY still does a great job working with the hard-to-read HTML code generated by specialized HTML code editors and conversion tools. At the same time, it can help you discover where in your site you need to devote more effort, making Web pages more user-friendly for people with disabilities.
What is the reason why we didn't use Tidy? When we started creating this site, we were already very familiar with XHTML. We were already aware of using lowercase tags and quoting attributes. So in the course of the website testing, we simply tested it through the Web-based XHTML validator and fixed a few bugs. More importantly, we've learned a lot about writing Tidy-style HTML code.
XHTML documents are validated against document type declarations.
Validating XHTML with DTDsXHTML documents are validated against a document type declaration (DTD). The XHTML file is validated correctly only if the correct DTD is added to the first line of the file.
A strict DTD contains elements and attributes that are not used or are not present in the framework structure:
! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
The staging DTD contains everything in the strict DTD, plus the elements and attributes that are deprecated.
! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "
The framework DTD contains everything in the transition DTD, plus the framework.
! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 frameset//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"
This is a simple XHTML document:
<! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >< Html>
Use the Web validator to test your XHTML for reasons of effect, to learn more please visit the original website: School website: http://www.w3school.com.cn/tags/index.asp about user geolocation:/http Www.haorooms.com/post/html5_GPS_getCurrentPositionThen I want to say: no more tete!!!
Check out XHTML First