HTML and CSS Reference
In-Depth Information
The Line Break Element
The line break tag, <br /> , is used to force a new line when the text on the Web page
document is displayed by a browser. The line break tag is used alone—it is not used as
a pair of opening and closing tags. It is considered to be a stand-alone or self-contained
tag. If you were using HTML syntax, the line break tag would be coded as <br> .
Because you are using XHTML (which follows XML syntax), the line break tag is
coded as <br /> (the ending /> indicates a self-contained tag).
Open your heading2.html file in Notepad. Place your cursor after the first sentence in
the paragraph (after “This is a sample paragraph about HTML and XHTML.”). Press
key. Save your page. Test your page in a browser and notice that even though
your source code showed the “This is a sample paragraph about HTML and XHTML.”
sentence on its own line, the browser did not render it that way. A <br /> tag is
needed to configure the browser. Open the heading2.html file in Notepad and add a
<br /> tag after the first sentence in the paragraph. Save your page as heading3.html.
Your source code should look similar to the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" lang="en" xml:lang="en">
<title>Sample Heading Tags</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<h1>Heading Level 1</h1>
<p>This is a sample paragraph about HTML and XHTML. <br /> XHTML is
the newest version of HTML. XHTML uses the tags and attributes of
HTML along with the syntax of XML.</p>
<h2>Heading Level 2</h2>
<h3>Heading Level 3</h3>
<h4>Heading Level 4</h4>
<h5>Heading Level 5</h5>
<h6>Heading Level 6</h6>
Launch a browser to test your page. It should look similar to the page shown in Figure
2.7. You can compare your work with the solution found in the student files
As you tested your Web pages, you may have noticed that the headings and text begin
near the left margin. This is called left alignment and is the default alignment for Web
pages. There are times when you want a paragraph or heading to be centered or right-
aligned (justified). The align attribute can be used for this. The purpose of an attribute
is to modify the properties of an XHTML element. In this case, the align attribute
Search WWH ::

Custom Search