Site icon Tutorial

Core Attributes

Core Attributes

They are used in most of the elements and consist of four attributes which are:

id Attribute

It identify a element uniquely in a page so as to link to that specific part in the document, or to specify a CSS style or JavaScript for that element in the document. The syntax is

id=” string ”

“string” is any chosen text value for the attribute. After identifying a unique element in the web page, it can be used for different purposes as

<p id=”paragraph1″>This is my first paragraph.</p>

p#paragraph1 { background: #0cf; }

<a href=”#paragraph1″>link to the first paragraph</a>

document.getElementById(“paragraph1”)

But some rules for usage of the id attribute are to be followed and which are

class Attribute

It is used to identify a group of elements so that styling or referring all those group of elements is made possible like to highlight specific paragraphs then a class attribute with same value, is to be added to all of them as

<p class=”highlight”>This is highlighted paragraph</p>

The syntax of the class attribute is

class= ”className ”

“className” is any chosen text value for the attribute. The value of attribute can have multiple text value which are separated by space as

class=” className1 className2 className3 ”

title Attribute

It assigns a title to the element. The syntax for it is

title=” string ”

“string” is any chosen text value for the attribute which is usually displayed as a tool tip.

style Attribute

It is used to specify CSS styling rules within the element in which it is present.

<p style=”font-family: courier;”>Text in courier.</p>

It is not used in XHTML 1.0 as separate CSS files are used for the purpose.

Exit mobile version