Home >Web Front-end >Front-end Q&A >How to open XHTML? What is the content of XHTML specification?

How to open XHTML? What is the content of XHTML specification?

寻∝梦
寻∝梦Original
2018-08-14 13:19:015538browse

How to open XHTML? What is the specification content of XHTML? This article will introduce to you in detail how to open HTML and what the content of the specification is.

First let us take a look at how to open XHTML:

Use You can see the effect with a browser, you can see the code with Notepad, or the professional Dreamweaver

xhtml is a language, generally files are html or htm, excluding dynamically generated pages

XHTML writing specification

This is a valid XHTML file writing specification:

A file that conforms to the XHTML standard can be called valid. This can ensure that the XHTML file code Coordination can also make files easier to process without having to ensure consistency in compilation by various browsers. The W3C verification service can verify whether the file is valid. In fact, many website development tools (such as Dreamweaver) support document verification based on W3C standards.

XHTML language must conform to the XML format, for example

Attribute names must be lowercase

  错误的:<table WIDTH="100%"> 
  正确的:<table width="100%">

Use double quotes for attribute values

  错误的:<table width=100%>
  正确的:<table width="100%">

Attribute abbreviations are not allowed

  错误的:<input checked> <input readonly> <input disabled> <option selected> <frame noresize>  
  正确的:<input checked="checked" /> <input readonly="readonly" /> <input disabled="disabled" /> <option selected="selected" /> <frame noresize="noresize" />

Use the id attribute to replace the name attribute

  这是错误的:<img src="picture.gif" name="picture1" /> 
  这是正确的:<img src="picture.gif" id="picture1" />

Note: For lower version browsers, you should use both the name and id attributes at the same time, and make their values ​​​​the same , like this:

<img src="picture.gif" id="picture1" name="picture1" />

This is a list of abbreviated attributes in HTML and how they should be written 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"

The purpose of these practices is to enable an XHTML web page to be Browsers compile correctly and faster. Valid XHTML file

Contents of XHTML specification:

1. All tags must have a corresponding closing tag

In the past in HTML, you could open many tags, such as e388a4556c0f65e1904146cc1a846bee and 25edfb22a4f469ecb59f1190150159c6 without necessarily writing the corresponding 94b3e26ee717c64999d7867364b1b4a3 and bed06894275b65c1ab86501b08a632eb to close them. But this is not legal in XHTML. XHTML requires a strict structure and all tags must be closed. If it is a separate unpaired tag, add a "/" at the end of the tag to close it. For example:

df250b2156c434f3390392d09b1c9563231a563c997aa9e3e0ae614bd16728b0

2. The names of all tag elements and attributes must be in lowercase

Unlike HTML, XHTML is case-sensitive, b2386ffb911b14667cb8f0f91ea547a7 and 08eb756f81b28a01d33212cce3fbe742 are different tags. XHTML requires that all tag and attribute names must be lowercase. For example: a64997a0904a094b4570728d7f327acd must be written as 6c04bd5ca3fcae76e30b72ad730ca86d. Mixed case is also not recognized. Usually the attribute name "onMouseOver" automatically generated by Dreamweaver must also be changed to "onmouseover".

3. All XML tags must be nested reasonably

Also because XHTML requires a strict structure, all nesting must be in order. Previously we Code written like this:

e388a4556c0f65e1904146cc1a846beea4b561c25d9afb9ac8dc4d70affff41994b3e26ee717c64999d7867364b1b4a3/b>

must be modified to:

e388a4556c0f65e1904146cc1a846bee43415385adddd72ebfd07f5b74615518/p>

That is to say, the nesting layer by layer must be strictly symmetrical.

4. All attributes must be enclosed in quotation marks ""

In HTML, you do not need to add quotation marks to attribute values, but in XHTML, they Must be quoted. For example:

ed8b4eb0ed7f9f7eb9eb4dba213e15f7 must be changed to: 344c3accbd0ffc6474892a394d76273b

In special cases, you need to use double quotes in the attribute value, you can use " , single quotes can use ', for example:

20ac24e1b34f8484bc0099397dad195b

5. Use encoding to represent all 41a5bfb3860d911c5cfb07ee63765b66), which is not part of the tag, must be encoded as Encoded as > ;

Any ampersand (&) that is not part of the entity must be encoded as &

6. Assign a value to all attributes

XHTML stipulates that all attributes must have a value, and if there is no value, it will repeat itself. For example:

904b6b39b75ef1127fe85748522f0103 55548d945501c58b536aa818f57f3033

Must be changed to:

37a18ab8d53860f3ed54fb3a38e08365 04ed464ee5a622903749fc3eaa46c0b7

7. Do not use "--" in the comment content

"--" can only occur at the beginning and end of XHTML comments End, that is, they are no longer valid in the content. For example, the following code is invalid:

5d3c7ac6aa007cff76dba65ef598f57e

Replace the internal dotted lines with equal signs or spaces.

e43c45488a32afc277655292ab7d8a0e

Okay, the above is about how to open XHTML and what the XHTML specification is.

[Related recommendations]

What is XHTML? Use XHTM L8’s big advantages

What is an HTML file? A preliminary understanding of HTML files

The above is the detailed content of How to open XHTML? What is the content of XHTML specification?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn