 |
OutPut Screen |
Basic Attributes
The four Basic attributes that can be used on the majority of HTML are:
Id:
The id attribute of an HTML tag can be used to uniquely identify any element within an HTML page.
If an element carries an id attribute as a unique identifier, it is possible to identify just that element and its content.
If you have two elements of the same name within a Web page (or style sheet), you can use the id attribute to distinguish between elements that have the same name.
Example
<p id = "html">This para explains what is HTML</p>
<p id = "css">This para explains what is Cascading Style Sheet</p>
title:
The title attribute gives a title for the element. They syntax for the title attribute is similar as explained for id attribute:
Example
<html>
<head>
<title>Attribute Example</title>
</head>
<body bgcolor="#993300">
<h3 title = "Hello HTML!;"style="font-size:19s;" align="center">Example of Title Attribute in Heading Tag iclude style attributes</h3>
</body>
</html>
 |
Output Screen |
Now try to bring your cursor over "Titled Heading Tag Example" and you will see that whatever title you used in your code is coming out as a tooltip of the cursor.
The class Attribute
The class attribute is used to associate an element with a style sheet, and specifies the class of element.
The value of the attribute may also be a space-separated list of class names. For example −
class = "className1 className2 className3"
The style Attribute
The style attribute allows you to specify Cascading Style Sheet (CSS) rules within element.
<html>
<head>
<title>Attribute Example</title>
</head>
<body bgcolor="#993300">
<h3 title = "Hello HTML!;"style="font-size:19s;" align="center">Example of Title Attribute in Heading Tag iclude style attributes</h3>
</body>
</html>
 |
Output Screen |
Internationalization Attributes
There are three internationalization attributes, which are available for most XHTML elements.
The dir Attribute
The dir attribute allows you to indicate to the browser about the direction in which the text should flow. The dir attribute can take one of two values, as you can see in the table that follows −
Value | Meaning |
ltr | Left to right (the default value) |
rtl | Right to left (for languages such as Hebrew or Arabic that are read right to left) |
Example
<html dir = "rtl"> <head>
<title>Display Directions</title>
</head>
<body>
This is how IE 5 renders right-to-left directed text.
</body>
</html>
When dir attribute is used within the <html> tag, it determines how text will be presented within the entire document. When used within another tag, it controls the text's direction for just the content of that tag.
The lang:
The lang attribute allows you to indicate the main language used in a document, but this attribute was kept in HTML only for backwards compatibility with earlier versions of HTML. This attribute has been replaced by the xml:lang attribute in new XHTML documents.
The values of the
lang attribute are ISO-639 standard two-character language codes. Check
HTML Language Codes: ISO 639 for a complete list of language codes.
Example
<html lang = "en">
<head>
<title>English Language Page</title>
</head>
<body>
This page is using English Language
</body>
</html>
Attribute | Options | Function |
align | right, left, center | Horizontally aligns tags |
valign | top, middle, bottom | Vertically aligns tags within an HTML element. |
bgcolor | numeric, hexidecimal, RGB values | Places a background color behind an element |
background | URL | Places a background image behind an element |
id | User Defined | Names an element for use with Cascading Style Sheets. |
class | User Defined | Classifies an element for use with Cascading Style Sheets. |
width | Numeric Value | Specifies the width of tables, images, or table cells. |
height | Numeric Value | Specifies the height of tables, images, or table cells. |
title | User Defined | "Pop-up" title of the elements. |
Comments
Post a Comment