XHTML Beginner's Tutorial: Understanding XHTML Syntax

Source: Internet
Author: User
xhtml| Beginners | tutorials | grammar

Writing XHTML code requires pure HTML syntax.

More XHTML Syntax rules:
  • Property name must be lowercase
  • Attribute values must be quoted
  • Attribute cannot be abbreviated
  • Replace the Name property with the id attribute
  • The XHTML DTD defines the HTML elements that are forced to use

Property name must be lowercase

This is wrong:

WIDTH= "100%" >

That's right:

width= "100%" >

Attribute values must be quoted

This is wrong:

<table width= 100% >

That's right:

<table width= "100%" >

Attribute cannot be abbreviated

This 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"/>

The following is a list of shorthand attributes for HTML, and a rewrite 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 property with the id attribute

HTML 4.01 defines the name attribute for the following elements: A, applet, frame, iframe, IMG, and map.

The use of the Name property is discouraged in XHTML 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 Properties (Lang)

The lang attribute applies to almost all XHTML elements. It defines the type of language in which the content inside the element is used.

If you use the lang attribute in an element, you must add an extra Xml:lang, like this:

lang="no" xml:lang="no">heia norge!</div>

The XHTML element that is forced to use

All XHTML documents must have a file type declaration (DOCTYPE declaration). The HTML, head, and body elements must exist in the XHTML document, and the title element must be located 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, and there is no closing tag.

Hint: it is necessary to,

You'll learn more about XHTML document type declarations in the next chapter.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.