div { border: 1px solid #000; }.
To apply a background color to all elements with the class highlight you would use the selector .highlight:
.highlight { background-color: yellow; }.
Finally, to change the width of an element with an ID attribute value of myDiv, you would use:
#myDiv { width: 250px; }.
Of
div#myDiv.
In addition to these straightforward selectors, CSS also includes (and has done since previous versions) a series of more complex selectors. For example you can use the selector
input[type="text"] to select only the input elements that contain an attribute type with the value of text. Or you can use the pseudo-class :hover to style anelement when the mouse is over it, for example:
a:hover { color:red; }.
There are many more of these selectors, all of which are provided to make it easier to select an element to style. With CSS3, even more new selectors have been added to the mix, all of which make developers' lives easier and reduce the amount of HTML and JavaScript they need to write.