HTML white-space and validation

HTML Space named entities (List of all HTML Entities)

In standard HTML any sequence of white-space characters is treated as a single space. There are HTML entities that you can use in your content to allow you to override the single space rendering. The area within the brackets below provides a visual display of the named entity. The zero-width entities provides no space at all.

  • &​zwj;     - zero-width joiner ligatures Note: renders as a character in IE7,Safari,Chrome
  • &​zwnj;    - zero-width non joiner ligatures Note: renders as a character in IE7,Safari,Chrome
  • &​#8203;   - zero-width space
  • &​thinsp; - ( ) thin space
  • &​nbsp;    - ( ) non-breaking space
  • &​ensp;    - ( ) en space 1/2 em space
  • &​emsp;    - ( ) em space 12 point font character size

The CSS property is white-space, and the XML attribute xml:space are also relevant.

Indenting in HTML

  • You can use several of the named space entities above to add the appropriate spacing needed to your content. It may be cleaner however to use margins in your HTML tags
  • Here is a1 inch space in a line using <​span style=”margin-left:1in;”>
  • You can pre-format text with <​pre> tag or style=”white-space:pre;” to circumvent the normal HTML single space rendering.
  • You can also indent using definition list tags <​dl><​dd> as shown here.

Validating HTML web pages

Tags: ,
If you like this post and would like to receive updates from this blog, please subscribe our feed. Subscribe via RSS

One Response to “HTML white-space and validation”

  1. Guest Says:

    Great quick guide on html white space and excellence reference on getting the W3C validator to ignore javascript!

    I also found a very interesting piece of information on the HOWTO reference link about the traditional method of hiding javascript from non-compliant browsers that is beginning to cause js to be completely ignored by the latest browsers. Great page and great links- thanks!

Leave a Reply