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.

Q: So, the only purpose of is to<br />

insert a linebreak?<br />

A: Right; the only place the browser typically<br />

inserts breaks in your content is when you start a<br />

new block element (like , , and so on). If<br />

you want to insert a linebreak into your text, then<br />

you use the element.<br />

Q: Why is called an “empty”<br />

element?<br />

A: Because it has no content, as in<br />

element = opening tag + content + closing tag.<br />

So, it’s empty because there’s no content.<br />

Q: I still don’t get it. Explain why the<br />

element is “empty”?<br />

A: Think about an element like (or <br />

or ). The whole point of the element is to tag<br />

some content, like:<br />

Don’t wait, order now<br />

With the element, the point is just to insert<br />

a linebreak into your <strong>HTML</strong>. There is no content<br />

you are trying to mark up, so it’s empty. Since<br />

it is empty, we don’t need all the extra brackets<br />

and markup, so we just shorten it into a more<br />

convenient form.<br />

If an element doesn’t need to mark up some text,<br />

then it is probably an empty element.<br />

Q: Are there any other empty elements?<br />

I think must be an empty element, too,<br />

right?<br />

there are no<br />

Dumb Questions<br />

A: Yes, there are a few of them. You’ve<br />

already seen us use the element, and we’ll<br />

be getting to the details of this element soon.<br />

Q: Can I make any element empty? For<br />

instance if I have a link, and don’t want to give<br />

it any content, can I just write<br />

instead?<br />

A: No. There are two types of elements in<br />

the world: normal elements, like , , and<br />

, and then there are empty elements, like<br />

and . You don’t switch back and forth<br />

between the two. For instance, if you just typed<br />

, that’s not an empty<br />

element – it’s an opening tag <strong>with</strong>out content and<br />

a closing tag.<br />

building blocks<br />

Elements that don’t have any <strong>HTML</strong><br />

content by design are called empty<br />

elements. When you need to use an<br />

empty element, like or ,<br />

you only use an opening tag. This is a<br />

convenient shorthand that reduces the<br />

amount of markup in your <strong>HTML</strong>.<br />

you are here 101

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

Saved successfully!

Ooh no, something went wrong!