Using HTML Tag Attributes

HTML tags provide the foundation for web pagehave to include the href attribute as in the following
design. To provide more flexibility with HTML design,example:
attributes have been defined for HTML tags to alterVisit our sponsor
the behavior of any particular HTML tag. There areThis piece of HTML code tells the browser that the
many instances while designing a web page whentext "Visit our sponsor" is the anchor text for a link.
you will want to change the default behavior of theWhen the user clicks on the anchor text, he is taken
tag. For instance, you might want to change theto the url
background color of the whole page or some sectionDisplaying a picture using the image tag
of the page. You might want to change theHTML pages would be pretty boring without the use
alignment of a section of text or apply a unique styleof images. The need to tell the browser where to
to a tag's representation. There are many instancesfind an image is a good example of how to use
when you would want to identify an HTML tag byHTML attributes. Images are included using . Similar to
giving it a name to identify it so that it can bethe anchor tag example above, using the tag alone
referred to elsewhere. Some tags, such as the onewouldn't suffice. The image tag attribute "src" is
used to present an image () don't do much ofrequired to tell the browser where to find the image
anything without having at least one attributeto be displayed, as in the following example:
defined. In the case of the image tag, you wouldThis block of code tells the browser to place an
need to have an attribute that tells the browserimage in the document. The browser is instructed to
where the find the image to be displayed.get the logo.gif image from the images folder located
Some Examples of HTML Attributesin the top level folder for the document. You also
Using bgcolor and background with the body tagnotice a width attribute defined in the tag. This
A very visible example of the effect of an attributeconstrains the image to be 150 pixels wide.
used in an HTML tag is changing the background colorConveniently, the height of the image is constrained
or image for the entire body of a web page.proportionally when the width attribute is defined.
Browsers understand that the contents of the tagHTML Attributes Reference
will be displayed on the main part of the web page.Don't feel like you have to memorize all the HTML
By default, the background used by browsers whentags and their corresponding attributes. Instead, it is
they encounter the tag is white. If you want aconvenient to access a reference when trying to
background color other than white, you would usedetermine which attributes can be used with
the bgcolor attribute. The following tag changes theparticular HTML tags. The official definition for HTML
background color of a web page from the defaulttags and attributes can be found at You can also find
white to gray:other resources for understanding the same
If you want to have an image comprise theinformation by using a search engine to search for
background for a web page, you could use the"html tags" or "html attributes"
following code:Beyond HTML Attributes
This example assumes that you have a folder onIn the mid-1990's, a methodology called Cascading
your web server called images, and that inside thatStyle Sheets (CSS) was developed for use in web
folder there is an image named background.gif. In thepages to make them more streamlined. CSS is a
case of a background image, if the image isn't largestandard for defining the layout and formatting for a
enough to fill the entire background of your webweb page. Many of the attributes that were
page, the browser will repeat the image vertically andcommonly used with HTML tags before CSS came
horizontally to fill the background.around are now handles by CSS definitions. For
Linking using the anchor tagdesigners unfamiliar with CSS or who, for whatever
The world wide web's fundamental usefulness hingesreason, don't choose to use CSS, HTML attributes
on its ability to link documents, providing web usersthat overlap with CSS definitions can still be used to
with a quick connection from one page to anotherchange the behavior of HTML tags. However, to be
related page. Linking documents in HTML is doneconsidered vogue in the world of web design, it is
using the anchor () tag. The anchor tag by itselfrecommended that you learn and use CSS.
doesn't tell the browser where to link. Instead, you