XHTML Tags Types
XHTML formatting codes, or tags, surround the material to be formatted and are
enclosed inside angled brackets ("<" and ">")
to identify them as markup instructions. On the basis of these markup tags the browser displays the
page in the specified layout and style. Each Web page is described by its own separate XHTML document
containing whatever tags are necessary to structure and style the page according to the design
envisioned by the page author.
Various types of XHTML tags are used for different layout and styling purposes. The list
below is one way to categorize tags according to their primary usages.
- Document Layout Tags. These tags are used to structure the XHTML document. They organize
the information content on a page so that text and graphical elements appear where you want them
to appear. These are the tags you use to design the overall physical and visual relationships between
page elements.
- Text Formatting Tags. These tags are used to apply font faces, styles, sizes, and colors to
the text appearing on the page. They package and decorate the text content of the page.
- List Formatting Tags. Certain tags are used to organize text information into lists.
List structures include bulleted lists, numbered lists, and others.
- Graphic Formatting Tags. These tags are used to position, size, and style drawings and
pictures that appear on the page.
- Linking Tags. Web pages are "hypertext" documents, meaning there are linkages between
them. With the click of a mouse you can jump from one page to another, or from one page to a
particular location on another page, immediately. It is not necessary to traverse the pages
sequentially. Therefore, certain tags are used to set up these linkages between pages and between
different sections of a single page.
- Table Tags. Web pages provide information to visitors. They present data. Often times
data need to be organized in tabular form, into rows and columns, for better presentation,
readability, and understanding. Table tags permit you to arrange data into tables; they also can
be used as structuring devices for laying out the entire content of Web pages.
- Frame Tags. Web pages can also be organized into frames, or into separate windows each
containing a different Web page that is accessible at the same time. Frame tags permit this
structural option for laying out information on a page.
- Form Tags. Forms are data collection devices. They are used to collect information from
visitors in order to capture data for processing or to solicit visitor preferences about content
displays. Forms are the mechanisms through which visitors interact with your Web page. A number of
different form tags permit various means of interaction.
- Multimedia Tags. Modern Web pages provide a multimedia experience, presenting
audio and video information and entertaiment as well as text and graphic images. Certain tags are
used to link to and play audio and video files through special media players that can be embedded
on the Web page.
This tutorial is organized around these tag types.
Web pages can be very simple or very complex depending on the amount of information they contain
and the fasion in which the information is organized and presented. The code below is a complete XHTML
document that displays just a single formatted line of text. Although this is about as simple as a
Web page can get, it does demonstrate how XHTML is used to identify the code as an
XHTML document, to structure the information to display inside the browser window, and to style
the text for presentation. Portions of this document shown in bold are XHTML tags that control the
browser display. The single line of regular text is the information content that is displayed in the
browser window.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD/XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml11-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<body>
<span style="font-family:times new roman; font-size:14pt; color:royalblue">
Here is text formatted by the browser.
</span>
</body>
</html>
The lines of code,
<span style="font-family:times new roman; font-size:14pt; color:royalblue">
Here is text formatted by the browser.
</span>
describe the text that appears in the browser window. Formatting is applied by surrounding the
text with tags (in this case with <span>...</span> tags) containing
styling information. Here the text is styled in Times New Roman font face at 14-point size and in
the color blue. The browser uses this styling information in the tag to render the text on screen.
The XML Language Family
The World Wide Web Consortium (W3C) (http://www.w3c.org)
is a voluntary organization responsible for setting HTML standards. Recent efforts have focused on
defining a new XML (eXtensible Markup Language) language for use as a universal
markup language, replacing older languages and with standards for creating future languages for
special markup needs. For instance, version of XML have been designed for generating Web graphics
(VML - Vector Markup Language), for displaying mathematical equations (MathML - Mathematical Markup
Language), for authoring interactive audio/video presentations (SMIL - Synchronized Multimedia
Integration Language), for digital signature recognition (InkML - Ink Markup Language), and others.
XHTML itself is a subset of the XML language.
XML is a highly structured language with precise rules for its use. These
rules are encompassed within a Document Type Definition (DTD), that is, a set of
coding criteria against which Web pages can be validated for conformity to XML standards.
A problem is that not all Web browsers can recognize XML; plus, there are millions of current Web
pages written under older HTML standards. So, as a transition between conventional HTML coding
and future XML coding, the W3C developed XHTML standards. These standards enforce the newer coding
practices of XML, while recognizing the older coding practices of HTML.
Coding a DTD Reference
In order to designate a Web document as conforming to XML coding standards, a Document Type
Definition is coded at the beginning of the document. The previous example contains the following
opening lines.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD/XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml11-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
The first line indicates that this document is based on XML version 1.0 (the current version)
standards. The second line, continuing through the third line, points to the Document Type Definition
for the particular standard being validated against. This line indicates the "transitional" standard,
one permitting conventional HTML as well as newer XML coding to appear on the page. The fourth line
specifies the standard's "namespace," that is, the location of the W3C standards from which the DTD is
drawn.
All Web pages should include these opening lines of code in order for the browser to validate the
document against these standards. This tutorial assumes these opening lines, although they are not
coded in all the examples so as not to detract from the coding topic at hand. All of the code shown
in these tutorials conforms to XHTML standards; however, older, "deprecated" HTML code that is being
phased out is shown for comparison. There are many existing Web pages coded in the older fashion, and
you need to recognize that coding as well as create pages using the newer coding.
XHTML Tag Keywords
XHTML tags are special keywords surrounded by "<" and
">" angle brackets. These tag "names" indicate the purpose of the
tag and direct the browser to treat the enclosed content in a specified fashion. In the above example
page the <html> tag surrounds all the content on the page
and indicates that this is an HTML document that the browser should treat as such. That is, the browser
should look for XHTML tags and use the enclosed markup specifications to style the
information surrounded by the tags. Likewise, <body> tags
enclose all page content that is displayed inside the browser window. Finally,
<span> tags encompass a string of text to which styling attributes are applied.
In conformance with XHTML standards all keywords are typed in lower-case characters.
Container Tags.