22.06.2015 Views

o_19octlt3v29m1ul81r9513q81i4ra.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

58 Chapter 4<br />

To add a horizontal line, simply add the following one-sided tag where you want the line<br />

to appear:<br />

<br />

Note In XHTML, you must add a space and closing slash, like this: . HTML5 also<br />

recognizes that syntax as an optional alternative. The slash is required for XHTML compatibility,<br />

while the space preceding the slash enables older browsers to read the tag correctly.<br />

By default, the line runs the entire width of the browser window, is two pixels in height,<br />

and is black with a chiseled effect. You can change these characteristics by applying<br />

attributes within the tag.<br />

Most of the original attributes for the tag were deprecated in HTML Version 4.01;<br />

attributes such as align, color, size, and width are not supported at all in HTML5. You<br />

now set the rendering characteristics for a horizontal line using styles, as you will learn in<br />

Chapter 6, “Introduction to Style Sheets.” It’s best to specify a uniform appearance for all<br />

lines with a cascading style sheet, as you’ll learn to do in Chapter 6, but you can also add<br />

styling directly to the tag by simply including the style=”attributes” attribute. The attributes<br />

you can set are color, background-color, width, and height. For example, to create a<br />

green line that is 3 pixels thick and spans 50% of the window’s width, you would write:<br />

<br />

Some browsers use color to assign a color to the line, others use background-color; therefore,<br />

you should include both tags and assign the same color for both.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!