The id attribute adds a unique identifier to an HTML element
You can reference the id name of title within your JavaScript or CSS. Here's a CSS example referencing the id of title to change the text color to red.
The hash symbol (#) in front of title, tells the computer you want to target an id with that value. id names should not be used more than once, and they should always be unique. Another thing to note about id values, is that they cannot have spaces in them. Here is an example of applying the words main and heading to an id attribute value:
In contrast to the id attribute, the class attribute value does not need to be unique and can contain spaces. Here is an example of applying a class called box to a div element.
If you wanted to add multiple class names to an element, you can do so by separating the names by a space. Here is an updated example applying multiple classes to a div element.
Classes are best used when you want to apply a set of styles to many elements. If you want to target a specific element, it is best to use id because those values need to be unique.