Indentation and Whitespce


#1

Can someone give me a brief about indentation, whitespace, tags and element.
Thank you


#2

In HTML whitespace is ignored (for the most part) so has no real meaning or affect on the rendering.

<p>This
text
will
render
on
the
same
line</p>

The line breaks act as a space character.

Indentation is used by many developers to help with reading and recognizing the structure of the document. A well formed HTML document will follow an outline of sorts with heirarchical headings, sections that are topical and closely related to the headings, and so on.

HTML consists mainly of a lot of containers, and in many instances there will be containers inside containers inside containers. This is known as nesting and where indentation proves very helpful to indicate the level of nesting for a given element.

<div>
  <h1>Subject</h1>
  <div>
    <h2>Section</h2>
    <p>textual content</p>
    <ul>
      <li>list item 1</li>
      <li>list item 2</li>
      <li>list item 3</li>
      <li>list item 4</li>
    </ul>
  </div>
</div>

Bottom line, neatness and legibility matter to the reader, even if it matters not to HTML.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.