CSS ID Selectors

The #id selector is used to select the element with a specific id attribute. The value of this attribute is the element's unique identifier. The class selector style apply on multiple elemnets but id selector style apply on unique element. 

ID Syntax

You declare a CSS id by using a dot (#) followed by the id name. You make up the id name by yourself. After the id name you simply enter the properties/values that you want to assign to your id.


Example of Code

<!DOCTYPE html>
<html lang="en">
  <title>Example of ID selector</title>
  <h1 id="heading">This is a heading</h1>
  <p>This is another paragraph.</p>


  Example of ID selector   

This is a heading


This is another paragraph.