Classes and IDs
The third tutorial video explains the difference between Classes and IDs, but if you do not want to watch it, then read on. We use Classes and IDs in CSS to style our HTML elements.
Think of the two like this. A Class (as in classroom) can be used by many different students at the same time. However, an ID (as in an Identity card) is only meant to be used by one single student.
Therefore, a class can be used by many different HTML elements at the same time, while an ID can only be used by one single HTML element.
We write a Class with a dot ( . ) in front of the name and an ID with a ( # ) in front of the name. For example:
Think of the two like this. A Class (as in classroom) can be used by many different students at the same time. However, an ID (as in an Identity card) is only meant to be used by one single student.
Therefore, a class can be used by many different HTML elements at the same time, while an ID can only be used by one single HTML element.
We write a Class with a dot ( . ) in front of the name and an ID with a ( # ) in front of the name. For example:
Leave a comment