Home > Articles

Document Structure Elements

Every XHTML document has three major components: the XHTML declaration, the head, and the body. The document structure elements are those that define each component.

<html>

Type:

Container

Function:

Declares the document to be an XHTML document. All document content and supporting XHTML code goes between the <html> and </html> elements.

Syntax:

<html> ... </html>

Attributes:

The <html> element can take the xmlns attribute, which specifies the URL that describes the XML namespace for the document (for example, xmlns="http://www.w3.org/1999/xhtml").

Example:

<html>
... all content and XHTML code goes here ...
</html>

Related Elements:

Although the <html> element is typically the first element in a document, it is sometimes preceded by a <!DOCTYPE> element that specifies which level of HTML conformance the document displays. A document conforming to the XHTML 1.0 standard might have a <!DOCTYPE> element that reads

<!DOCTYPE XML PUBLIC "-//W3C//DTD XHTML 1.0//EN">

Technically, <!DOCTYPE> is an SGML element, not an HTML element, so it is acceptable for it to be outside the <html> and </html> elements.

<head>

Type:

Container

Function:

Contains the elements that compose the document head.

Syntax:

<head> ... </head>

Attributes:

<head> can take the profile attribute, which gets set equal to a space-separated list of URLs that point to meta-data profiles for the document. The profiles could describe the nature of the content, who wrote it, how it was published, and so on.

Example:

<html>
<head profile="http://www.server.com/profiles/">
... elements making up the document head go here ...
</head>
... all other content and XHTML code goes here ...
</html>

Related Elements:

Several elements can be placed between the <head> and </head> elements, including <base/>, <link/>, <meta/>, <script>, <style>, and <title>. Each of these is described next.

NOTE

The <ISINDEX> tag, which has been deprecated from HTML, does not have an equivalent in XHTML.

<base />

Type:

Standalone

Function:

Declares a global reference value for href and target attributes. The reference or base href value is used as a basis for computing all relative URL references. The base target value indicates which frame in a frameset is targeted by default.

Syntax:

<base href="base_url" />

or

<base target="base_target" />

Attributes:

A given <base /> element takes either the href or the target attribute, but not both at the same time. The usage of each attribute follows:

  • href—Specifies the reference URL that is used to help compute relative URLs. If the base href URL is http://www.myserver.com/sports/hockey/skates.html and you use the relative URL pucks.html elsewhere in the document, for example, the relative URL will really point to http://www.myserver.com/sports/hockey/pucks.html.

  • target—Used to direct the results of a hyperlink click or a form submission to a particular frame in the frameset. A common use of this attribute is to set target="main" in a frame that contains navigation links. This results in the linked documents being loaded into the frame called "main" rather than being loaded into the navigation frame itself.

NOTE

When used in a <base> element, href is typically set to the URL of the document.

Example:

<head>
<base href="http://www.myserver.com/index.html/" />
<base target="main" />
...
</head>

This code sets the document's base URL to http://www.myserver.com/index.html.

<meta />

Type:

Standalone

Function:

Defines document meta-information, such as keywords, expiration date, author, page-generation software used, and many other document-specific items. It also supports the notion of client pull—a dynamic document technique in which the browser loads a new document after a specified delay.

Syntax:

<meta http-equiv="header" content="value" />

or

<meta name="name" content="value" />

Attributes:

The <meta /> element takes the following attributes:

  • http-equiv—Specifies a type of HTTP header to be sent with the document. The value of the header is given by the content attribute. The two most commonly used values of http-equiv are refresh, which refreshes the page after a specified delay, and expires, which gives the date after which content in the document is not considered to be reliable.

  • name—Set equal to the name of the document meta-variable you want to specify. The value of the variable is given in the content attribute. Typical values for name include author, keywords, generator, and description. The keywords value is particularly useful for specifying words you want a search engine's indexing program to associate with the page.

  • scheme—Provides information on how to interpret the meta-variable. For example, with the following <meta/> element:

    <meta scheme="9-digit-ZipCode" name="zip" content="02134-1078"/>

    a browser might not know how to interpret "02134-1078" without information from the scheme attribute.

  • content—Specifies either the HTTP header or the value of the meta-variable.

Example:

<head>
<!-- The first <meta/> element instructs the browser
to load a new page after 5 seconds. -->
<!-- This is useful for creating a splash screen effect. -->
<meta http-equiv="refresh"
content="5; URL=http://www.myserver.com/index2.html" />
<!-- The remaining <meta /> elements specify author and keyword information. -->
<meta name="author" content="Eric Ladd" />
<meta name="keywords" content="Main page, welcome, neat stuff" />
...
</head>

<link />

Type:

Standalone

Function:

Denotes the linking relationship between two files.

Syntax:

<link href="url_of_linked_file" title="title"
rel="forward_relationship" rev="reverse_relationship" />

Attributes:

The <link /> element takes the following attributes:

  • charset—Denotes which character encoding scheme to use.

  • href—Set equal to the URL of the file to which you're making the linking reference.

  • hreflang—Specifies the language code for the linked file.

  • media—Provides the intended display destination for the linked document. The default value of media is screen.

  • rel—Specifies the relationship of the linked file to the current file.

  • rev—Specifies how the current file relates to the linked file.

  • target—Specifies which frame to target.

  • title—Gives the link a descriptive title.

  • type—Specifies the MIME type of the linked file.

Table 3.3 shows some possible values for rel and rev and what these values mean.

Table 3.3 Possible Values for the rel and rev Attributes

Value

Meaning

copyright

Web site's copyright page

glossary

Glossary of terms for a site

help

Site help page

home

Site home page

index

Site index page

made

Mail to URL pointing to the email address of the page author

next

Page that logically follows the current page

previous

Page that precedes the current page

stylesheet

File containing style information for the page

toc

Site table of contents

up

Page that is above the current page in a site's hierarchy


NOTE

Because so many types of linked files exist, it is permissible to have more than one <link /> element in a document. 

Example:

<head>
<link href="/style/styles.css" rel="stylesheet" />
<link href="/index.html" rel="home" />
<link href="/help.html" rel="help" />
<link href="back_one.html" rev="previous" />
...
</head>

<script>

Type:

Container

Function:

Contains script code referenced in the body of the document.

Syntax:

<script type="scripting_language MIME type">
... script code goes here ...
</script>

Attributes:

The <script> element can take the following attributes:

  • charset—Denotes which character encoding scheme to use.

  • defer—Specifying the defer attribute tells the browser that the script does not generate any document content. This enables the browser to continue parsing and rendering the document without having to execute the script.

  • src—Specifies the URL of a file containing the script code, if not contained between the <script> and </script> elements.

  • type—Set equal to the MIME type of the script code, usually text/javascript or text/vbscript. When specifying a specific version of a scripting language, you can set type equal to a value that includes version information as well (for example, type="text/javascript1.1"). type is a required attribute under XHTML 1.0.

NOTE

The <script> element also takes the xml:space attribute, which tells processing programs to preserve whitespace within the element. 

Example:

<script type="text/vbscript">
Sub ScriptEx
document.write("<hr/>")
document.write("<h1>Thank you for your submission!</h1>")
document.write("<hr/>")

</script>

TIP

Traditionally, script code is often placed between <!-- and --> elements so that browsers that can't process scripts will treat the code as a comment. However, under XHTML, a parser can remove what's contained inside a comment. Therefore, hiding your scripts with comment delimiters will probably not serve you well when writing for XHTML browsers.

Related Elements:

You can use the <noscript> element to specify what a browser should do if it's unable to execute a script contained in the <script> and </script> elements.

<noscript>

Type:

Container

Function:

Provides alternative content to use if a script cannot be executed. A browser might not be able to execute a script because the user has turned scripting off or because it does not know the scripting language used to write the script.

Syntax:

<noscript>
... alternative to script code goes here ...
</noscript>

Attributes:

None.

Example:

<script type="text/javascript">
  document.write("Hello, World!");
</script>
<noscript>
  You either have scripting turned off or your browser does not
  understand JavaScript.
</noscript>

<style>

Type:

Container

Function:

Specifies style information for the document.

Syntax:

<style type="mime_type" media="media_type" title="title">
... style information goes here ...
</style>

Attributes:

The <style> element takes the following three attributes:

  • media—Specifies what media types the styles are to be used for (visual browser, speech-based browser, Braille browser, and so on).

  • title—Gives the style information a descriptive title.

  • type—Set equal to the Internet content type for the style language. You will most likely use type="text/css2" to denote the use of the style language put forward in the Cascading Style Sheets, Level 1 specification. type is a required attribute of the <style> element.

NOTE

The <style> element also takes the xml:space attribute, which tells processing programs to preserve whitespace within the element.

Example:

<style type="text/css2">
<!--
  body {font: 10 pt Palatino; color: silver margin-left: 0.25 in}
  h1 {font: 18 pt Palatino; font-weight: bold}
  h2 {font: 16 pt Palatino; font-weight: bold}
  p {font: 12 pt Arial; line-height: 14 pt; text-indent: 0.25 in}
-->
</style>

NOTE

Style information has traditionally been placed between <!-- and --> elements so browsers that cannot process it will treat the style information as a comment. However, this is not recommended for XHTML documents since an XHTML parser is free to remove contents inside of comments. 

<title>

Type:

Container

Function:

Gives a descriptive title to a document. Use of the <title> element is required by the XHTML 1.0 DTD for many good reasons. Titles show up in browser window title bars and in bookmark and history listings. In each of these cases, you provide an important reader service when you specify a title because otherwise the browser displays just the document's URL. Additionally, Web search engines, such as Yahoo! and AltaVista, frequently look for title information when they index a document.

Syntax:

<title> ... document title goes here ... </title>

Attributes:

None.

Example:

<title>
XHTML Tutorial
</title>

TIP

Try to keep titles to 40 characters or fewer so that browsers can display them completely.

<body>

Type:

Container

Function:

Contains all content and elements that compose the document body.

Syntax:

<body>
 ... document body goes here ...
</body>

Attributes:

None.

NOTE

The popular <BODY> tag attributes used in HTML--BGCOLOR, BACKGROUND, TEXT, LINK, VLINK, and ALINK—do not have equivalents under the Strict XHTML DTD. You should use style sheets to specify these display characteristics or use the Transitional DTD instead.

NOTE

The <body> element is not allowed under the XHTML Frameset DTD.

Example:

<body>
... all document body content and XHTML code goes here ...
</body>

Related Elements:

Dozens of elements are allowed inside the <body> element. In fact, with the exception of some of the frame-related elements, any element in the rest of the chapter can be placed between <body> and </body>.

By putting together what you've learned in this section, you can come up with a generic XHTML document template such as the following:

<html>
<head>
<title>Document Template</title>
... <meta />, <base />, <link />, <script>, <style> elements ...
</head>
<body>
... document body content and elements ...
</body>
</html>

When creating a new document, you can use this code to get started, and then fill in elements and other information according to your needs.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020