ID is a CSS selector that allows the styling of a single unique element.
Their use in CSS is common and often a little controversial.
I personally avoid ID for styling things in CSS, but I’m not going to force my personal preferences on you.
In this video, I will outline some of the reasons why I prefer the class selector over ID, how CSS specificity works and some tips for writing more modular and reusable code.
Syntax
Let’s start with the basics and look at how ID can be used to select an element in CSS.
Given this series of <div>, if I wanted the third one to be a feature box, I could add an id attribute to the HTML as follows. This is a unique identifier, a bit like your passport number or social security number and there can be only one with this value on any given page.
Continue reading %AtoZ CSS Screencast: The ID Selector%
by Guy Routledge via SitePoint
No comments:
Post a Comment