Roadmap to becoming a developer in 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

538 B

An id is a unique identifier for a single HTML element. A class is a reusable identifier that can be applied to multiple elements.

ID vs Class in HTML

You’d want to use an id when you need to address a single element either through CSS or JavaScript. And you’ll want to use a class when you need to address a group of DOM elements.

In CSS:

  • #id selects a specific element with that id.
  • .class selects all elements with that class.