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.

That’s interesting because<br />

I noticed the text inside the<br />

is all inside other block elements,<br />

like , , and . So, if textalign<br />

is aligning inline elements in the<br />

block element, how is the text<br />

in these nested block elements<br />

getting aligned?<br />

Good catch. All the text inside the <br />

element is in nested block elements, but it is<br />

all aligned now. That’s because these block<br />

elements inherit the text-align property<br />

from the . So here’s the difference:<br />

rather than the itself aligning the<br />

text in the headings and the paragraphs<br />

(which it won’t do because these are block<br />

elements), the headings and paragraphs<br />

are inheriting the text-align value of<br />

“center”, and then aligning their own content<br />

to center.<br />

So what? Well, if you think about it, this<br />

gives you a lot of leverage when you use a<br />

, because you can wrap a section of<br />

content in a and then apply styles<br />

to the rather than each individual<br />

element. Of course, keep in mind that not<br />

all properties are inherited by default, so<br />

this won’t work for all properties.<br />

divs and spans<br />

you are here 449

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

Saved successfully!

Ooh no, something went wrong!