HTML ID & Classes

What Is ID

ID
Unique Identifier - ID Is A Unique Identifier That Can Be Given To Any One Element Like Div Or Span If You Want To Give The Same ID To Another Element So That Can't Be Done You Can Give It Another ID Like Example Below

What Is Class

Class
The class attribute lets you give the same name to multiple HTML elements. That way, you can easily change their look or behavior all at once. Classes are not unique and can be assigned to multiple elements. They are generally used for applying the same styles or behaviors to a group of elements.

I'm A Div With ID firstdiv And Two Classes red And bg-yellow.
I'm Another Div With ID seconddiv And One Class red.
I'm A Span With Class bg-yellow. I'm Another Span With Same Class bg-yellow.

ID And Class Are Attributes In A Element Not An Element Themselve.

ID Also Helps In Linking Like If You Click On Given Link Below So You'll Be Redirected To ID Named lastdiv In Same Page And You Can Check It By Inspecting In Chrome Browser.

Go To Last Div

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

You Got Me I'm The Last Div In This Page

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.