What’s the Difference Between Classes and IDs in CSS?

Learn the potential effects of using either of these selectors

When applying CSS styles to an element in your HTML, you’ll be using different CSS selectors to target your elements. Two of the most common selectors used in CSS are the “class” selector and the “ID” selector. There are many others, but this post will focus on these two.

 

Don’t use IDs as CSS selectors unless you have really good, practical reasons for doing so. Use classes abundantly and allow the natural cascade to work its magic.

Daniela Vaseva

Daniela VasevaDaniela is writing tutorials, news, newsletters, and update emails for the DMXzone specialising in the sphere of electronic processing, analysis and publication of texts, and interested in the development of new Internet technologies and problems related to the cyberculture and net literature. She has a bachelor's degree in Bulgarian philology, and a master's degree in computational linguistics.

See All Postings From Daniela Vaseva >>

Comments

Be the first to write a comment

You must me logged in to write a comment.