Introducing spaces and new lines with character entities
Sponsored Links
When displaying the web page, browsers collapse and ignore, spaces, tabs and new line characters in the HTML. You might have spent a lot of time formatting a document using spaces only to be surprised at its display in a browser. Let us check this out.
This contains ten space characters. A new line character has been inserted. And here are 2 tabs before this line.
is displayed in the browser as:
This contains ten space characters. A new line character has been inserted. And here are 2 tabs before this line.
You'll notice that the 10 spaces, new lines and tabs that were visible in the code above are not shown by the browser, though you will find them in the source code (VIEW-SOURCE or PAGE SOURCE).
The only HTML tag that preserves such characters and this formatting is <pre> and I have used it for code display (as above), but <pre> renders the font as fixedspaced!
Web developers employ various tricks to achieve indentation and introduce spaces in their documents. They use list tags - <ol>, <ul> and <li> - or <blockquote>. This is not advisable as HTML has a special character for introducing spaces, (lowercase).
Placing 8 will display equivalent number of space characters
8
8
If you're wondering what nbsp; means; it stands for non-breaking space character. The is an HTML character entity. There are tons of these and you can go through them at list of character entities.
For introducing new lines, use <br> tag (or <br />, if you are using XHTML).
Page contents: details on formatting web pages correctly by introducing new lines and spaces created with HTML character entities.
Comments, questions, feedback... whatever!
Recent Articles
Recent Blog Posts
Popular Articles
- Hotmail Sign In page
- Create a Hotmail account - Instructions
- Create Gmail address
- Download and install Outlook Express
- Get your free Gmail address
- Outlook Express new version
- Create my own email address
- Browers for Windows list
- Get email address
- Color combinations for web sites and pages
- Create Yahoo ID
More web tips & tricks
- Outlook Express Help - tips & tricks (53)
- Windows Live Mail help and tips (36)
- Windows Mail help (25)
- Hotmail help and tips (42)
- Yahoo help & support (45)
- AOL email help (26)
- Gmail help and tips (36)
- Internet tips & tricks (12)
- Web Design tips & tricks (33)
- HTML, Javascript tips tricks (68)
- Web Promotion tips & tricks (8)
- Graphics tips & tricks (20)
