2.2. HTML ELEMENTS WITH ATTRIBUTES
29
2.2
HTML elements with attributes
The most general form of HTML tags is as follows:
.....
where A1,A2,...,An are the names of attributes that are allowed for that tag,
and V1,V2,...,Vn are values that those attributes can accept. In general,
the attributes should always be enclosed in double quotes as this will simplify
migration to XHTML which is poised to become the successor to HTML4.0 as
the next interational standard.
For example, to include an image in a webpage you use the img tag as follows:
The src attribute of the image tag specifies the name of the image file to
display, the alt attribute specifies the closed captioned reading of the image,
and the width specifies the size to make the picture (in pixels). In this case,
the attributes are used to provide information needed to properly display the
element.
For another example, the tag allows one to specify the background
color of the page using the bgcolor attribute and to specify the color of the
text on the page using the text attribute. It also has attributes for specifying
the color of unvisited links link, already visited links vlink, and links that are
being clicked alink.
For example, the following HTML specifies a page with red letters on a black
background and also specifies the link colors:
....
2.3
Style and class attributes
One of the most common problems encountered when writing HTML pages is
that each tag has its own set of attributes, and one must know which attributes
are allowed for which tags. For example, almost all tags have a bgcolor at
tribute, but body is the only tag with a text attribute. The CSS language,
discussed in detail in the next section, was developed partly in response to this
problem. It provides a uniform method of specifying the style (e.g. color, font,
border, etc.) of any HTML tag. For example, the CSS method for specifying
the red on black body tag shown above is the following:
test
....