HTML Attributes

HTML Attributes

HTML tags can contain one or more attributes. Attributes are added to a tag to provide the browser with more information about how the tag should appear or behave. Attributes consist of a name and a value separated by an equals (=) sign.

Example

Consider this example:

<body style="background-color:orange">
OK, we've already seen the body tag in previous lessons, but this time we can see that something extra has been added to the tag - an attribute. This particular attribute statement, style="background-color:orange", tells the browser to style the body element with a background color of orange.

The browser knows to make the background color orange because we are using standard HTML tags and attributes (along with standard Cascading Style Sheets code) for setting the color.

Another Example

Here's another example of adding an attribute to an HTML tag. In this example, we use the <a> tag to create a hyperlink to the Quackit website.

<a href="http://www.quackit.com">Quackit Website</a>

This results in:

Many attributes are available to HTML elements, some are common across most tags, others can only be used on certain tags. Some of the more common attributes are:

Attribute Description Possible Values
class Used with Cascading Style Sheets (CSS) (the name of a predefined class)
style Used with Cascading Style Sheets (CSS) (You enter CSS code to specify how the way the HTML element is presented)
title Can be used to display a "tooltip" for your elements. (You supply the text)

You don't need to fully comprehend these just yet. The good thing about attributes is that, in most cases, they are optional. Many HTML elements assign a default value to its attributes - meaning that, if you don't include that attribute, a value will be assigned anyway. Having said that, some HTML tags do require an attribute (such as the hyperlink example above).

You will see more attributes being used as we cover off some of the more advanced HTML elements.

Clock
 
Zain Merchant's Elance
 
Shoutbox
 
Online Users
 
รับพนันกีฬา
 
https://sportbettingthailand.wordpress.com/
 
Total Number Of Hits: 162060 visitors (736438 hits) Since 19th/November/2008
cy)dots.com This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free