HTML Tutorials - Attributes

HTML Tutorials: Attribute and Formatting

In HTML tags can have attributes, which are extra bits of information about the tag in question. Html Attribute appears inside the opening tag and its values are always inside quotation marks.

Example:

<tag attribute=”value”>Element </tag>

HTML attribute allows us to change background colors or perhaps change the width of a tables. All of these things and more can be achieved using Attributes.

Example:

<body style="background-color:red;">

In the above example we use the style attribute, the style attribute allows us to change the layout and color of our page. By using the above html code our web page background is set to red.

We could of used a hex value to represent our color each color in html has its own hexadecimal number.

<body style="background-color: #FF0000;">
 
Also we could of said
 
        <body bgcolor=”red”>

When you create a Web page, you can change several attributes in the body of your document by adding extra commands to the <body> tag. Here is what a body tag with several additions would look like:


<body bgcolor="red" text="black" link="yellow" alink="green" vlink="white" background="imagebackground.gif">


text="color"   - This changes the default text color the browser will display on your page.
link="color" - This changes the color of all of the non-visited links on your page
alink="color" This changes the color of an active link on your page
vlink="color" This changes the color of a visited link on your page
background="imagebackground.gif"  - This adds a background image to your page.


Atrributes are widely used in html and most tags have attributes, another example would be the align attribute – this attribute allows us left, center or right align our text. This is what we also call html formatting.


<h2 align="center">Centered Heading</h2>

More attributes examples are

<font face="times new roman" size="4" color="green">This text is using the 'times new roman' font face. It's relative size is '4' and the color is 'green'.</font>

That’s it for attributes, please move to the next lesson.

C++ Functions Tutorial