04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

testing the padding<br />

A test drive <strong>with</strong> some padding<br />

When you reload the page in your browser, you’ll notice the text<br />

in the guarantee paragraph has a little more breathing room<br />

on the sides now. There’s some space between the text and the<br />

border, and it’s much easier to read.<br />

Now you can see 25 pixels of space between the<br />

edge of the text content and the border.<br />

Now let’s add some margin<br />

Margins are easy to add using <strong>CSS</strong>. Like padding, you can<br />

specify the margin as a percentage or in pixels. You’re going to<br />

add a 30-pixel margin around the entire guarantee paragraph.<br />

Here’s how you do that:<br />

.guarantee {<br />

border-color: black;<br />

border-width: 1px;<br />

border-style: solid;<br />

background-color: #a7cece;<br />

padding: 25px;<br />

margin: 30px;<br />

}<br />

402 Chapter 10<br />

Notice that the background<br />

color is under both the content<br />

and the padding. But it doesn’t<br />

extend into the margin.<br />

We’re adding 30 pixels of margin to all sides of the<br />

content (top, right, bottom, and left).

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

Saved successfully!

Ooh no, something went wrong!