XHTML syntax

编写 XHTML 代码需要纯净的 HTML 语法。

更多的 XHTML 语法规则:

  • атрибут ари ахалан вара ари ари ара
  • атрибут ари ахалан вара ари вара
  • атрибут ахалан вара ара
  • 用 Id 属性代替 name 属性
  • XHTML DTD 定义了强制使用的 HTML 元素

атрибут ари ахалан вара ари ари ара

Yau, wannan na kai wani:

<table WIDTH="100%">

Yau, wannan na yi aiki:

<table width="100%">

атрибут ари ахалан вара ари вара

Yau, wannan na kai wani:

<table width=100%>

Yau, wannan na yi aiki:

<table width="100%">

атрибут ахалан вара ара

Yau, wannan na kai wani:

<input checked>
<input readonly>
<input disabled>
<option selected>
<frame noresize>

Yau, wannan na yi aiki:

<input checked="checked" />
<input readonly="readonly" />
<input disabled="disabled" />
<option selected="selected" />
<frame noresize="noresize" />

ни гези вани HTML ацигин ара ари ара, ки вани 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"

Amfani da id don mayar da name

HTML 4.01 ta bayyana attribute name ga sunan kai kai: a, applet, frame, iframe, img, da map.

Ana kai kama amfani da attribute name a cikin XHTML, kuma a fi a kama amfani da id.

Yau, wannan na kai wani:

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

Yau, wannan na yi aiki:

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

Tushin yaranci na a samu:

Kuwanan kuma ya wajin da a yi kama kai kai da saurin kai kai, kuma a fi a kama wata kai kai a kai / kai tsawon kai, domin XHTML zai amsa kwayar kwayar alhakin aiki a cikin browsers na yau.

Sunan Yaranci (lang)

Attribute lang na a yi amfani da wa kusan duki kai kai na XHTML. Ya bayyana nau'in yaranci na a cikin duki na kowane kewayar element.

Tun daga kuma ya wajin da a kama lang ce kuwa, ana da dauri xml:lang, dake:

<div lang="no" xml:lang="no">Heia Norge!</div>

Kwamitin XHTML na a samu

Alli hawuni XHTML ya bace sunan gudan (DOCTYPE tushin). Ina hawuni hawuni XHTML, ana dace sunan html, head, body, kuma yau sunan title ya dace a cikin elementin head.

Iya, yau shi yauwarin XHTML koyi yake:

<!DOCTYPE Dokumentin Doyin na a yin wajen hcinan>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Headline na alhakin</title>
</head>
<body>
</body>
</html>

Tip:The file type declaration is not part of the actual content of the XHTML document. It is not an XHTML element and does not have a closing tag.

Tip:In XHTML, the xmlns attribute within the <html> tag is required. However, even if this attribute is not present in the XHTML document, the w3.org validation tool will not prompt an error. This is because, "xmlns=http://www.w3.org/1999/xhtml" is a fixed value, and this value will be added to the <html> tag even if you do not include it in the code.

You will learn more about the knowledge of XHTML document type declarations in the next chapter.