HTML Attributes
Core Attributes
Core Attributes
The four Core Attributes that can be used on the majority of HTML element are:
- id
- title
- class
- style
The id attribute
The id Attribute can be used to uniquely identify any element with a page.
Syntax
id="idName"
Example of id attribute
The id attribute could be used to distinguish between two paragraph element.
<!DOCTYPE html> <html> <body> <p id="p1" > Programming, learn HTML , CSS , PHP <p> <p id="p2" >id attribute<p> </body> </html>
HTML Document Output
Programming, learn HTML , CSS , PHP
id attribute
The tilte attribute
The title attribute give a suggested title for the element.
The Behavior of this can carry title attribute will depend upon the element that carries it,although it is often displayed as a tooltip or while the extenal is loading.
Syntax
title="titleName"
Example of title attribute
<!DOCTYPE html> <html> <body> <p title="html-learning">learn HTML , CSS , PHP <p> </body> </html>
HTML Document Output
learn HTML , CSS , PHP
The style attribute
The Class attribute is used to specify that an element belong to a class of element.
Syntax
class="ClassName"
Example of style attribute
<!DOCTYPE html> <html> <body> <p class="history">learn HTML , CSS , PHP <p> </body> </html>
HTML Document Output
learn HTML , CSS , PHP
The Class attribute
The Style attribute allows to specify CSS rule within the element.
Syntax
class="ClassName"
Example of Class attribute
<!DOCTYPE html> <html> <body> <p style="font-size:20px;border:1px;color:#338844;"> learn HTML , CSS , PHP <p> </body> </html>
HTML Document Output
learn HTML , CSS , PHP
Internationalization Attributes
Internationalization Attributes
There are three internationalization attributes, which are available to most (although not all) XHTML elements.
- dir
- lang
- xml:lang
The dir Attribute:
The dir attribute allows you to indicate to the browser 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 of dir Attribute
<!DOCTYPE html> <html dir=rtl> <body> <p>This is how IE 5 renders right-to-left directed text. <p> </body> </html>
- 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.
- When included within the <html> tag, the lang attribute specifies the language you’ve generally used within the document. When used within other tags, the lang attribute specifies the language you used within that tag’s content. Ideally, the browser will use lang to better render the text for the user.
The lang Attribute:
The dir attribute allows you to indicate to the browser 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:
Example of lang Attribute
<!DOCTYPE html> <html lang=en> <body> <p>The page is using English language<p> </body> </html>
0 Comments: