HTML and CSS Reference
In-Depth Information
In Chapter 1 we said that an element
is an opening tag + content + closing
tag. So how is <br> an element? It doesn't
have any content, and it doesn't even
have a closing tag.
Exactly. It doesn't have any content.
The <br> element is an element that doesn't have any content. Why?
Because it's just meant to be a linebreak, nothing else. So, when an
element doesn't have any real content by design, we just use a shorthand
to represent the element and it ends up looking like <br> . After all, if we
didn't have this shorthand, you'd be writing <br></br> every time you
needed a linebreak, and how much sense does that make?
They used
to be called
“empty
elements,”
which
apparently
made too
much sense, so
they renamed
them to void.
Personally, we
still like empty.
<br> isn't the only element like this; there are others, and we have a name
for them: void elements . In fact, we've already seen another void element,
the <img> element. We'll be coming back to look at the <img> element in
detail in a couple chapters.
Keep in mind, the reason for the shorthand isn't laziness so much as it is
efficiency. It's more efficient to represent void elements this way (efficient
in typing, in the number of characters that end up in a page, and so on).
In fact, after reading HTML for a while, you'll find that it is easier on
your eyes too.
Content? H mm, the whole point of
this element is to insert a linebreak.
There's real ly no content.
Here' s the openi ng ta g.
<br> </br>
<br> </br>
I'm half the
element I used to
be…(sniff sniff).
Yeah, if we just type this,
then it really represents
the same thing.
<br>
Search WWH ::




Custom Search