Coding For Dummies
Book image
Explore Book Buy On Amazon

HTML has basic capabilities to style content. Here, you learn how to do some basic text formatting in HTML, such as adding text characteristics like boldface and how to add super- and subscript.

Highlighting with bold, italics, underline, and strikethrough

HTML allows for basic text styling using the following elements:

  • strong marks important text, which the browser displays as bold.

  • em marks emphasized text, which the browser displays as italicized.

  • u marks text as underlined.

  • del marks deleted text, which the browser displays as strikethrough.

The underline element is not typically used for text because it can lead to confusion. Hyperlinks, after all, are underlined by default.

To use these elements, start with the element’s opening tag, followed by the affected text, and then a closing tag, as follows:

Affected text

Some examples:

image0.jpg
Grace Hopper,  a US Navy rear admiral , popularized the term "debugging."
Bill Gates co-founded a company called Microsoft.
Stuart Russell and Peter Norvig wrote a book called Artificial Intelligence: A Modern Approach.
Mark Zuckerberg created a website called Nosebook Facebook.
Steve Jobs co-founded a company called Peach Apple

You can apply multiple effects to text by using multiple HTML tags. Always close the most recently opened tag first and then the next most recently used tag. For an example, look at the last line of code and the tags applied to the word Peach.

Raising and lowering text with superscript and subscript

Reference works like Wikipedia, and technical papers often use superscript for footnotes and subscript for chemical names. To apply these styles, use the elements

  • sup for text marked as superscript

  • sub for text marked as subscript

To use these elements, start with the element’s opening tag, followed by the affected text, and then a closing tag as follows:

Affected text

Two examples:

The University of Pennsylvania announced to the public the first electronic general-purpose computer, named ENIAC, on February 14, 1946.1

The Centers for Disease Control and Prevention recommends drinking several glasses of H20 per day.

When using the superscript element to mark footnotes, use an anchor tag to link directly to the footnote so the reader can view the footnote easily.

image1.jpg

About This Article

This article is from the book:

About the book author:

Nikhil Abraham is the CFO of Udacity, an education company that teaches technology skills that help launch or advance a career. Prior to joining Udacity, Abraham worked at Codecademy, where he taught beginning coders across a variety of professions. He is also author of Coding For Dummies and Getting a Coding Job For Dummies.

This article can be found in the category: