HTML - Id Attribute

HTML Id Attribute

The id attribute is used as a unique identifier for an HTML element. It can be used to add styles and function to a particular element.

How To Style

This is how to point a particular styling to an id

  • Inside the <style> tag in your <head> tag. First write the hash character #.
  • Followed by the name (value) of the attribute #mypara1
  • Add opening and closing curly braces { } and define your styling inside it. #mypara1 { font-size: 40px; color: orange; }.

Example

Case Sensitivity

Id values (names) are case sensitive. mypara1 is NOT the same thing as Mypara1.

note
NOTE:

Id values (names) must contain at least one character
The character cannot start with a number.
Values (names) must NOT contain white spaces.

ADVERTISEMENTS

LEARNING IS A CONTINOUS PROCESS - PRACTICE MAKES PERFECT