Skip to content

Challenge Use an ID Attribute to Style an Element

SaintPeter edited this page · 1 revision
Clone this wiki locally

One cool thing about id attributes is that, like classes, you can style them using CSS.

Here's an example of how you can take your element with the id attribute of cat-photo-element and give it the background color of green.

In your style element: #cat-photo-element { background-color: green; }

Note that inside your style element, you always reference classes by putting a . in front of their names. You always reference ids by putting a # in front of their names.

Something went wrong with that request. Please try again.