XHTML and CSS - Paragraphs and Line Breaks
Paragraphs and Line Breaks
First type out the example below and view it in your browser.
<!DOCTYPE html> <html> <head> <title> This is the title. </title> </head> <body> This is text in the body tag. This is another line of text in your body tag. </body> </html>
As you can see it's all showing up on one line, this is because XHTML is white space insensitive. What this means is even though you see the space, your browser reads it all in one line and doesn't know you want new lines. There are two ways around doing this in XHTML, the first one is by surrounding the paragraphs with paragraph tags like in the example below.
<html> <head> <title> This is the title. </title> </head> <body> <p>This is text in the body tag.</p> <p>This is another line of text in your body tag.</p> </body> </html>
You can also use a line brake like in the example below to end the line rather then putting the next line into a new paragraph.
<html> <head> <title> This is the title. </title> </head> <body> This is text in the body tag.<br/> This is another line of text in your body tag. </body> </html>
You might be wondering why line brakes don't have opening and closing tags, whenever you make a line brake the browser doesn't need to know when the tag starts like a body tag and when it ends as it only brakes onto a new line. In normal closing tags we put the forward slash before the keyword but in single tags we put the forward slash after the keyword, this is the same in all of XHTML's single tags, image tags, horizontal line tags etc, but we'll get into those in future tutorials.

Page generated in 0.0052 seconds.