White Space in HTML Pages

The Web Book

Example 1 (Whitespace Not Preserved)

Success is a journey not a destination.

Success is a journey not a destination.

Success is a journey not a destination.

Example 2 (Whitespace Preserved)

      An example of preformatted text.
      It preserves      both spaces
      and line breaks.
   

Usually applied to display computer program code:

      if a = 1
         c=c+1
      end if
   

HTML White Space Example Code

<!DOCTYPE html> <html> <body> <p><b>Example 1</b></p> <p>Success is a journey not a destination.</p> <p>Success is a journey not a destination.</p> <p>Success is a journey not a destination.</p> <p><b>Example 2</b></p> <pre> An example of preformatted text. It preserves both spaces and line breaks. </pre> <p>Usually applied to display computer program code:</p> <pre> if a = 1 c=c+1 end if </pre> </body> </html> Back