04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

adding style to a div<br />

Adding a border<br />

Okay, now that you have a around all the elements in the elixirs<br />

section, the fun begins: you can style it.<br />

The first thing we want to reproduce in the elixirs handout is a border that<br />

wraps around all the elements in the elixirs section, right? Well, now that<br />

you actually have a element that wraps around the elixirs section,<br />

you can style it and add a border. Let’s try that now.<br />

You’ll need a new rule in the lounge’s <strong>CSS</strong> to select the element<br />

using its id. Open up your “lounge.css” file in the “chapter11/lounge”<br />

folder, and add this rule at the end:<br />

#elixirs {<br />

border-width: thin;<br />

border-style: solid;<br />

border-color: #007e7e;<br />

}<br />

An over-the-border test drive<br />

After you’ve added the <strong>CSS</strong>, save it and then reload<br />

your “lounge.html” file.<br />

440 Chapter 11<br />

Here’s the border that you just added<br />

to the elixirs element.<br />

You added a visible border<br />

to this , but it still has<br />

no padding and no margin.<br />

We’ll need to add that too.<br />

Notice that the border goes<br />

around all the elements inside<br />

the element. The <br />

is a box like every other<br />

element, so, when you add<br />

a border, the border goes<br />

around the content, which is<br />

all the elements in the .<br />

Add this at the end of your <strong>CSS</strong> file. It<br />

selects the elixirs element using its id,<br />

and adds a thin, solid border in our favorite<br />

aquamarine color.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!