HTML Core Elements


The four Core Attributes that can be used on the majority of XHTML element are:

  1. id
  2. title
  3. class
  4. 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.

<html>
        <head>
        <title> Welcome to HTML Tutorial</title>
        </head>
        <body>
        <p id="p1" > Programming, learn HTML , CSS , PHP </p>
        <p id="p2" >id attribute</p>
        </body>
</html>

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

<html>
 <head>
  <title> Welcome to HTML Tutorial</title>
 </head>
 <body>
  <p title="Fastlearning.in">learn HTML , CSS , PHP </p>
 </body>
</html>

The Class attribute

The Class attribute is used to specify that an element belong to a class of element.

Syntax

class="ClassName"

Example of class attribute

<html>
 <head>
   <title> Welcome to HTML Tutorial</title>
 </head>
 <body>
  <p class="history">learn HTML , CSS , PHP </p>
 </body>
</html>

The style attribute

The Style attributeallows to specify CSS rule within the element.

Example of class attribute

<html>
 <head>
  <title> Welcome to HTMl Tutorial</title>
 </head>
 <body>
  <p style=”font-size:20px;border:1px; color:#338844;"> learn HTML , CSS , PHP </p>
 </body>
</html>

Share this article on