Course Content
HTML Introduction
0/1
HTML Editors
0/1
HTML Basic Tags
0/1
HTML Elements
0/1
HTML Attributes
0/1
HTML Headings
0/1
HTML Paragraph
0/1
HTML Text Formatting
0/1
HTML Meta Tags
0/1
HTML Quotations
0/1
HTML Comments
0/1
HTML Images
0/1
HTML Background
0/1
HTML Colors
0/1
HTML Lists
0/1
HTML Tables
0/1
HTML Forms
0/1
HTML Spell Check
0/1
HTML Media
0/1
HTML Marquees
0/1
HTML CSS
0/1
HTML Links
0/1
HTML Block & Inline
0/1
HTML Classes
0/1
HTML Id
0/1
HTML I frames
0/1
HTML Java script
0/1
HTML File paths
0/1
HTML Layout
0/1
HTML Responsive
0/1
HTML Computer Code
0/1
HTML Tutorial
About Lesson

HTML Id

In this tutorial, we will learn about id in HTML with the help of examples.


Id

The id attribute is used to specify a unique id for an element in an HTML document.
It is used by CSS and JavaScript to perform certain tasks for a unique element.
We cannot use more than one element with the same id in an HTML document.
The value of the id attribute must be unique within the HTML document.


Using Id Attribute

An Id name can be defined within the <style> element, or in the external CSS file.
The id name is case sensitive.
To create a id, write a hash # character followed by a id name.

Syntax :

#idName

Example :

<!DOCTYPE html>
<html>
  <head>
    <title>HTML Id</title>
    <style>
      #cricket {
        color : blue;
      }
      #football {
        color : green;
      }
    </style>
  </head>
  <body>
    <p id = "cricket">This is a paragraph with cricket id.</p>
    <p id = "football">This is a paragraph with football id.</p>
  </body>
</html>

Output

This is a paragraph with cricket id.

This is a paragraph with football id.

Exercise Files
No Attachment Found
No Attachment Found
error: Content is protected !!