Clean XHTML syntax

Clean XHTML syntax
Writing XHTML demands a clean HTML syntax.
Writing XHTML requires using clean HTML syntax
--------------------------------------------------------------------------------
Some More XHTML Syntax Rules:
More XHTML syntax rules:
Attribute names must be in lower case
Attribute names must be lowercase
Attribute values ​​must be quoted
Use double quotes for attribute values
Attribute minimization is forbidden
Property shorthand is not allowed
The id attribute replaces the name attribute
Use the id attribute instead of the name attribute
The XHTML DTD defines mandatory elements
XHTML DTD defines mandatory elements
--------------------------------------------------------------------------------
Attribute Names Must Be In Lower Case
Attribute names must be lowercase
This is wrong:
This is wrong:
<table WIDTH="100%">This is correct:
that's right:
<table width="100%">
--------------------------------------------------------------------------------
Attribute Values ​​Must Be Quoted
Attribute values ​​must be enclosed in double quotes
This is wrong:
This is wrong:
<table width=100%>This is correct:
that's right:
<table width="100%">
--------------------------------------------------------------------------------
Attribute Minimization Is Forbidden
Property shorthand is not allowed
This is wrong:
This is wrong:
<input checked>
<input readonly>
<input disabled>
<option selected>
<frame noresize>This is correct:
The correct answer is this:
<input checked="checked" />
<input readonly="readonly" />
<input disabled="disabled" />
<option selected="selected" />
<frame noresize="noresize" />Here is a list of the minimized attributes in HTML and how they should be written in XHTML:
Here is a list of attributes that are shorthand 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 id Attribute Replaces The name Attribute
The id attribute replaces the name attribute
HTML 4.01 defines a name attribute for the elements a, applet, frame, iframe, img, and map. In XHTML the name attribute is deprecated. Use id instead.
For a, applet, frame, iframe, img and map, HTML 4.01 defines a name attribute, which is deprecated in XHTML and should be replaced by id.
This is wrong:
This is wrong:
<img src="picture.gif" name="picture1" />This is correct:
that's right:
<img src="picture.gif" id="picture1" />Note: To interoperate with older browsers for a while, you should use both name and id, with identical attribute values, like this:
Note: For older browsers, you should use both the name and id attributes and make them both have the same value, like this:
<img src="picture.gif" id="picture1" name="picture1" />IMPORTANT Compatibility Note:
Compatibility notes:
To make your XHTML compatible with today''s browsers, you should add an extra space before the "/" symbol.
To make your XHTML compatible with current browsers you should add a space before the / tag

--------------------------------------------------------------------------------
The Lang Attribute
Lang Attributes
The lang attribute applies to almost every XHTML element. It specifies the language of the content within an element.
The lang attribute can be applied to almost all XHTML elements. It specifies the language of the content within the element
If you use the lang attribute in an element, you must add the xml:lang attribute, like this:
If you want to apply the lang attribute to an element, you must add the xml:lang attribute, like this:
<div lang="no" xml:lang="no">Heia Norge!</div>
--------------------------------------------------------------------------------
Mandatory XHTML Elements
Mandatory XHTML Elements
All XHTML documents must have a DOCTYPE declaration. The html, head and body elements must be present, and the title must be present inside the head element.
All XHTML documents must have a DOCTYPE declaration. The html, head, and body elements must appear, and the title must be in the head element
This is a minimum XHTML document template:
This is a minimal XHTML document template
<!DOCTYPE Doctype goes here>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title goes here</title>
</head><body>
Body text goes here
</body></html>Note: The DOCTYPE declaration is not a part of the XHTML document itself. It is not an XHTML element, and it should not have a closing tag.
Note: The DOCTYPE declaration is not part of the XHTML document itself. It is not an XHTML element either, and it should not have a closing tag.
Note: The xmlns attribute inside the <html> tag is required in XHTML. However, the validator on w3.org does not complain when this attribute is missing in an XHTML document. This is because "xmlns=http://www.w3.org/1999/xhtml" is a fixed value and will be added to the <html> tag even if you do not include it.
Note: XHTML documents require the xmlns attribute to appear within the html tag. However, the w3.org validator will not report an error due to the absence of this attribute in your XHTML document. This is because "xmlns=http://www.w3.org/1999/xhtml" is a fixed value, even if your document does not contain it, it will be automatically added.
You will learn more about the XHTML document type definition in the next chapter

<<:  MySQL database rename fast and safe method (3 kinds)

>>:  A brief discussion on Vue3 father-son value transfer

Recommend

Detailed installation and use tutorial of mysql 8.0.15 under windows

This article shares with you the detailed install...

Parse CSS to extract image theme color function (tips)

background It all started when a classmate in the...

Analysis of the principles and usage of Docker container data volumes

What is a container data volume If the data is in...

Summary of methods to include file contents in HTML files

In the forum, netizens often ask, can I read the ...

A brief talk about the diff algorithm in Vue

Table of contents Overview Virtual Dom principle ...

JavaScript implements the detailed process of stack structure

Table of contents 1. Understanding the stack stru...

JavaScript canvas implements moving the ball following the mouse

This article example shares the specific code of ...

Detailed explanation of formatting numbers in MySQL

Recently, due to work needs, I need to format num...

Detailed explanation of MySQL custom functions and stored procedures

Preface This article mainly introduces the releva...

How does the composite index of MySQL take effect?

Table of contents background Understanding compos...

JavaScript to achieve full or reverse selection effect in form

This article shares the specific code of JavaScri...

Vue button permission control introduction

Table of contents 1. Steps 1. Define buttom permi...

Detailed graphic explanation of sqlmap injection

Table of contents 1. We found that this website m...

Solution to the paging error problem of MySQL one-to-many association query

The query data in the xml price inquiry contains ...