Home

How to Use Emphasis and Strong Emphasis for HTML5 and CSS3 Programming

|
|  Updated:  
2016-03-26 13:16:10
HTML5 and CSS3 All-in-One For Dummies
Explore Book
Buy On Amazon

You may be shocked to know that HTML5 doesn't allow italics or bold. Old-style HTML had the tag for italics and the tag for bold. These seem easy to use and understand.

Unfortunately, they can trap you. In your HTML5, you shouldn't specify how something should be styled. You should specify instead the purpose of the styling. The and tags in XHTML Strict are removed in HTML5 and replaced with and .

The tag means emphasized. By default, italicizes your text. The tag stands for strong emphasis. It defaults to bold.

image0.jpg

The code for the page is pretty straightforward. It has no CSS at all:

<!DOCTYPE html>
<html lang = "en-US">
 <head>
 <meta charset = "UTF-8">
 <title>emphasis.html</title>
 </head>
 <body>
 <h1>Emphasis and Strong Emphasis</h1>
 <p>
  This paragraph illustrates two main kinds of emphasis.
  <em>This sentence uses the em tag.</em>
  By default, emphasis is italic.
  <strong>This sentence uses strong emphasis.</strong>
  The default formatting of strong emphasis is bold.
 </p>
 <p>
  Of course you can change the formatting with CSS.
  This is a great example of <em>semantic</em> formatting.
  Rather than indicating the <strong>formatting</strong>
  of some text, you indicate <strong>how much it is emphasized.</strong>
 </p>
 <p>
  This way, you can go back and change things, like adding color
  to emphasized text without the formatting commands
  muddying your actual text.
 </p>
 </body>
</html>

It'd be improper to think that is just another way to say italic and is another way to say bold. In the old scheme, after you define something as italic, you're pretty much stuck with that. The HTML way describes the meaning, and you can define it how you want.

About This Article

This article is from the book: 

About the book author:

Andy Harris earned a degree in Special Education from Indiana University/Purdue University–Indianapolis (IUPUI). He taught young adults with severe disabilities for several years. He also taught himself enough computer programming to support his teaching habit with freelance programming.
Those were the exciting days when computers started to have hard drives, and some computers connected to each other with arcane protocols. He taught programming in those days because it was fun.
Eventually, Andy decided to teach computer science full time, and he still teaches at IUPUI. He lectures in the applied computing program and runs the streaming media lab. He also teaches classes in whatever programming language is in demand at the time. He has developed a large number of online video-based courses and international distance education projects.
Andy has written several books on various computing topics and languages including Java, C#, mobile computing, JavaScript, and PHP/MySQL.
Andy welcomes comments and suggestions about his books. He can be reached at [email protected].