Breaks

A couple of other peculiarities of HTML involve the handling of line breaks and spaces.  HTML does not recognize redundant spaces and collapses all to one space.  This will be discussed in greater detail when we discuss symbols (turns out you need to use the symbol for the space character to retain extra spaces).

Similarly, just because your HTML editor of choice wraps text to the next line when you reach the right side of your viewing window, does not mean that the web page when rendered will insert a line-feed character.  When you start a new <p>aragraph</p>, you will break to the next line, but sometimes you may want short lines of text within the paragraph. For that reason when you need to force a line break into your page, you will need to use the <br /> tag.  This tag is one of those exceptions where you use a single tag as opposed to requiring an opening and closing tag.

 

 
 <html>
  <head>
  </head>       
   <body>
    <p>When you want short lines<br />
    like this<br />
    use the break tag like I do here.
    </p>
    <p>A new paragraph.</p>
   </body>
</html>

When you want short lines
like this
use the break tag like I do here.

A new paragraph.

Lines


A simple way to break your pages into sections for readability is to use lines or horizontal rules as they are called in HTML.  This is another tag which does not abide by the concept of an opening and closing tag.  The horizontal rule is written simply as <hr /> and it can be used freely within your pages.  The <hr />* tag comes with a number of attributes which can draw fancier and more precise lines.  Some examples below:

This is your standard horizontal line: <hr />


This is a thicker black line: <hr size="6" color="black">


 We specified that it be 6 pixels high and black in color.

It also could have been red in color: <hr size="6" color="red">


 Maybe we only wanted it to use 50% of the available area: <hr size="6" color="red" width="50%">


Maybe 50% was fine, but we wanted it right justified:  

<hr size="6" color="red" width="50%" align="right">


Get the idea?

* Note that certain tags which do not conform to the opening tag/closing tag syntax can currently be written one of two ways.  For instance, <br> is the same as <br />.  The latter being the preferred syntax in order to conform to W3C specifications. <return>

 

Previous Page

Next Page

 


Email:   

raykelly@rakelly.com