What is "white space" in HTML?

A

Andy Dingley

devdixon said:
Can anyone explain "white space" to me?

White space is what separates the "interesting stuff" apart.

- "White space" can be any white-space characater: space, tab,
linefeed or a few others, it doesn't matter.

- "White space" is often found in HTML, but rarely needed. Because
tags have clear stop and start characters ("<" and ">") then you can
usually manage without needing to deliberately space them apart with
whitespace.

- "White space" means a gap, it doesn't matter how big the gap is.
HTML doesn't care if you leave lots of spaces or just enough, it'll
render the same.

- "White space" is of varying significance, depending on the context
(even depending on the browser). In some places it doesn't matter if
you have any or not (between most tags) in some cases you have to avoid
having _any_ whitespace or you'll see annoying gaps appearing (most
infamously around <a> tags mixed with <li> or <img> tags).


The rest is in the W3C HTML spec. If you're starting to care about
these issues, you should be reading the real spec, not some bowdlerised
tutorial site version of it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top