Your browser does not support JavaScript!
Upvotes Anonymous 1 User 0

How to Style a Single Element with CSS

In HTML, we can give an element an ID:
<div id="banana">Banana</div>
If you assign an ID to an element, it should be unique on the page (e.g. above, there shouldn't be any other element on the page with the ID of banana).

To style the element above, we can put this in our CSS file:
#banana {
    background-color: yellow;
    font-size: 30px;
    font-weight: bold;
    font-family: Arial;
}
The # helps us select an element by ID.

The result:
Was this helpful?

Comments

Leave a Comment

I agree to the Terms of Service
Design © 2015, Downranked, LLC.,
Original user code contributions under MIT License