anandgp Posted February 21, 2015 Share Posted February 21, 2015 Hi, I am not able to understand the difference between a class and an id. Both of them define property and it's value. .container { min-width: 900px; } #top { background-color: #84c754; color: #ffffff; padding: 15px; } -------------------------------------- <div class="container"> <div id="top"> <h1>Welcome to My Homepage</h1> </div> </div> Regards, -Anand Link to comment Share on other sites More sharing options...
Ingolme Posted February 21, 2015 Share Posted February 21, 2015 The id is used when you want to reference an element that is unique, when there is only one on the page. A class can be used to give a same style to multiple different elements. The id is also used by Javascript to easily access an element. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now