10.07.2017 Views

246996016-HTML5-Step-by-Step

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Applying Strikethrough and Underlining 115<br />

Most Web designers don’t use underlining as a formatting technique because hyperlinks<br />

are underlined, and it is considered poor design to confuse your users with text that<br />

looks “clickable” but is not. In the example just shown, for instance, you might think that<br />

the text Now only $9.99 is a hyperlink, but it’s not; it’s just underlined.<br />

If you simply want to underline or strike through a few words of text in one specific<br />

instance that probably won’t recur elsewhere on your page (or site), it’s easiest to use<br />

the tag for underlining or the tag for strikethrough. These tag names come<br />

from the logical functions that underlining and strikethrough often serve in an edited<br />

document; insertions are commonly underlined, and deletions are commonly struck<br />

through. Here’s the code for the preceding example:<br />

List price: $24.00 Now only $9.99<br />

Note In early HTML versions, there was a or tag for strikethrough and a tag<br />

for underlining, but both were deprecated in HTML4 and removed completely in <strong>HTML5</strong>. The<br />

and tags will probably become deprecated at some point, but for now they are still<br />

in use.<br />

To strike through or underline text <strong>by</strong> using a style (a more modern and “correct”<br />

method, although it requires a little more typing), use the text-decoration attribute. This<br />

attribute accepts several keywords:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

underline<br />

overline (line over the text)<br />

line-through (strikethrough)<br />

blink (flashing text)<br />

none (removes all inherited decoration)<br />

Caution Do not use blinking text if at all possible. It is quite annoying. Visitors to your site will<br />

probably dislike it so much that they will leave your site and never return.<br />

You can use the none keyword to remove the underlining from text that would ordinarily<br />

be underlined automatically, such as a hyperlink. Be careful, though, because if you<br />

remove the underline from a hyperlink, many people will not realize they can click it.<br />

Here are some examples applied to individual paragraphs:<br />

This looks clickable, but isn’t.<br />

This is struck-through.<br />

Congratulations, you win!

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

Saved successfully!

Ooh no, something went wrong!