HOME    articles    tutorials    tool directory    about

Free Email
META Tag Generator



Tags Can Have Attributes with Values

The effect a particular tag has can be further specified through the use of attributes, which is a fancy word for options. For example, if you want the background color of your document to be white, you can accomplish that by adding the attribute BGCOLOR to the <BODY> tag, like this:

<BODY bgcolor="White">

Notice that you also have to specify a value for that attribute, in this case "White", so that Web browsers know which background color to use. Attributes and values are only included in the opening tag of a pair, not the closing tag. A tag can have more than one attribute, or no attributes at all. Although this might sound confusing at first, you'll quickly get the hang of it because it's largely based on common sense.

Consider the tag to insert an image into your document, for example. The tag itself is <IMG>. This alone doesn't tell the browser which image to use, whether or not to put a border around it, how to position it on the page, or what size to make it. At the very least, you're going to want to specify which image to display, and whether to position in the left, right, or center of the page.

If you're following good HTML coding practices, you'll also want to specify the size (which will make it load more smoothly) and provide an alternate text description of the image. The text description makes it possible for people who can't view the images - either because they've set their browser not to load images or because they are visually impaired and are using special tools to view your site - to know what the image is about. So the final image tag, with attributes (and values), would end up looking like this:

<IMG src="\images\JimDilbert.jpg" align="left" height=210 width=202 alt="Photo of Jim">

The order of the attributes doesn't matter, nor does whether you write them in uppercase (all capitals), lowercase (no capitals), or mixed case. The only place where case matters is the file name. Unix-based systems, which are widely used for Web hosting, consider "JimDilbert.jpg" and "jimdilbert.jpg" to be two different files. If you wish to follow standard conventions, write your tag name in uppercase, and the attributes and values in lowercase.

Some tags have no attributes at all associated with them. The <BR> tag is used to create a line break (or new line) in a document. It stands alone, with no attributes and no closing tag because none are needed.

previous pagenext page


HOME    articles    tutorials    tool directory    about

(c) copyright 2000-2010 Anventure.  All Rights Reserved.
privacy policy