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.

there are no<br />

Dumb Questions<br />

Q: Should I always use shorthand?<br />

A: Not necessarily. Some people find the long form more<br />

readable. Shorthands do have the advantage of reducing the size<br />

of your <strong>CSS</strong> files, and certainly they are more quickly entered<br />

because they require less typing. However, when there is a<br />

problem, they are a little more difficult to “debug” if you have<br />

incorrect values or the wrong order. So, you should use whichever<br />

form is more comfortable because they are both perfectly valid.<br />

Q: Shorthands are more complex because I have to<br />

remember the ordering and what is and isn’t optional. How do<br />

I memorize it all?<br />

A: Well, you’ll be surprised how quickly it becomes second<br />

nature, but those of us in the “biz” have a little secret we like to call<br />

Exercise<br />

divs and spans<br />

It’s time to put all your new knowledge to work. You’ll notice that at the bottom of the lounge, there’s a small<br />

section <strong>with</strong> copyright information that acts as a footer for the page. Add a to make this into its own<br />

logical section. After you’ve done that style it <strong>with</strong> these properties:<br />

font-size: 50%;<br />

text-align: center;<br />

line-height: normal;<br />

margin-top: 30px;<br />

And let’s add some top margin to give the<br />

footer a little breathing room.<br />

Let’s make the text really small.<br />

You know, FINE PRINT.<br />

And let’s center the text.<br />

Make it Stick<br />

We’re also setting the line-height to be<br />

“normal”, which is a keyword you haven’t seen<br />

yet. “Normal” allows the browser to pick an<br />

appropriate size for the line-height, which is<br />

typically based on the font.<br />

To remember the<br />

ordering of the padding<br />

and margin shorthand<br />

values, think of a<br />

clock labelled <strong>with</strong> top,<br />

right, bottom, and left.<br />

Then, always go in a<br />

clockwise direction: top<br />

to right to bottom to left.<br />

margin: 0px 20px 30px 10px;<br />

And while you’re at it, have a look over the entire “lounge.css” file. Is there anywhere you might want to<br />

simplify things <strong>with</strong> shorthands? If so, go ahead and make those changes.<br />

top<br />

right<br />

left<br />

bottom<br />

a “reference manual.” Just pick one up, and should you need<br />

to quickly look up property names or the syntax of a property,<br />

just grab your handy reference manual and look it up. We’re<br />

particularly fond of the <strong>CSS</strong> Pocket Reference by Eric Meyer.<br />

It’s tiny and makes a great reference.<br />

you are here 461

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

Saved successfully!

Ooh no, something went wrong!