Core Attributes

Certify and Increase Opportunity.
Be
Govt. Certified HTML5 Developer

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

  • id
  • title
  • class
  • style

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

  • CSS Styling of just that one element as

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

p#paragraph1 { background: #0cf; }

  • Jump to that specific portion by using it in ‘href’ attribute as

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

  • Reference that element in scripts as

document.getElementById(“paragraph1”)

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

  • The first character should be a letter (A–Z or a–z) and then any number of letters, digits, hyphens, underscores, colons, and periods.
  • It should be unique and no two id attributes should have same value in a web page.
  •  Earlier ‘name’ attribute was used for same purpose but ‘name’ attribute is now used only in transitional XHTML.

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.

Get industry recognized certification – Contact us

Menu