Lynxbee
In this post, we will demonstrate the basic difference between Id and Class in html element styled with CSS.
Let us consider the below simple example html code, where we have create two ID and two Class in CSS.
When we open this html page in browser, we will see it displayed as,
The declaration “Id” is started with hash “#” and declaration of “class” is started with dot “.”
In below example, example Id is declared as “#exampleId1” and example class is declared as “.exampleClass1”
Only one ID can be attached with the one element, but we can attach more than one Class with one element in html.
Below use of “exampleId1” and “exampleId2” is invalid, as it wont show error but it will not achive the actual result as can be seen for Para2.
Below use of “exampleClass1” and “exampleClass2” is valid and we can see the Para4 showing the proper result of converting the paragraph text to capital with background set.
To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video
Sign up to our newsletter!
Notify me of follow-up comments by email.
Notify me of new posts by email.
Δ
Join 1,027 other subscribers
Subscribe
Enter your email address to subscribe to this blog and receive notifications of new posts by email.
Join 1,027 other subscribers
Subscribe