Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Responsive Web Design with HTML5 and CSS

You're reading from   Responsive Web Design with HTML5 and CSS Develop future-proof responsive websites using the latest HTML5 and CSS techniques

Arrow left icon
Product type Paperback
Published in Apr 2020
Publisher Packt
ISBN-13 9781839211560
Length 408 pages
Edition 3rd Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Ben Frain Ben Frain
Author Profile Icon Ben Frain
Ben Frain
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. The Essentials of Responsive Web Design 2. Writing HTML Markup FREE CHAPTER 3. Media Queries – Supporting Differing Viewports 4. Fluid Layout, Flexbox, and Responsive Images 5. Layout with CSS Grid 6. CSS Selectors, Typography, Color Modes, and More 7. Stunning Aesthetics with CSS 8. Using SVGs for Resolution Independence 9. Transitions, Transformations, and Animations 10. Conquer Forms with HTML5 and CSS 11. Bonus Techniques and Parting Advice 12. Other Books You May Enjoy
13. Index

HTML text-level semantics

Before HTML5, text-level semantic elements were referred to in the specifications as inline elements. Therefore, if you are familiar with that description, be aware that we are talking about the same thing here.

The section of the HTML specification that details text-level semantics can be found here: http://www.w3.org/TR/html5/text-level-semantics.html#text-level-semantics.

Let's take a look at the most common and useful text-level elements.

The <span> element

The span element is the text-level equivalent of a div. It is unopinionated and is the perfect element to reach for when you merely want to wrap text in an element for styling purposes.

The <b> element

Historically, visuals were defined in the markup and the <b> element meant "make this bold" (http://www.w3.org/TR/html4/present/graphics.html#edef-B). However, the specification now describes the <b> element like this:

The b element represents a span of text to which attention is being drawn for utilitarian purposes without conveying any extra importance and with no implication of an alternate voice or mood, such as key words in a document abstract, product names in a review, actionable words in interactive text-driven software, or an article lede.

Although no specific meaning is now attached to it, as it's text level, it's not intended to be used to surround large groups of markup. Use a div for that.

You should also be aware that because it was historically used to bold text, you'll typically have to reset the font-weight in CSS if you want content within a <b> tag to not appear bold.

For example:

b {
    font-weight: normal;
}

The <strong> element

If you do want to emphasize something for strength, urgency, or importance, <strong> is the element for you. Here is how the specification defines these use cases:

Importance: The strong element can be used in a heading, caption, or paragraph to distinguish the part that really matters from other parts that might be more detailed, more jovial, or merely boilerplate.

Seriousness: The strong element can be used to mark up a warning or caution notice.

Urgency: The strong element can be used to denote contents that the user needs to see sooner than other parts of the document."

You can read the full specification for <strong> here:

https://www.w3.org/TR/html52/textlevel-semantics.html#the-strong-element

The <em> element

I'll admit, in the past, I've often used <em> merely as a styling hook to provide italic text when I wanted it. I need to mend my ways as the HTML specification tells us:

The em element represents stress emphasis of its contents.

Therefore, unless you actually want the enclosed contents to be emphasized, consider using a <b> tag or, where relevant, an <i> or span tag instead.

The <i> element

The HTML5 specification describes the <i> as:

A span of text in an alternate voice or mood, or otherwise offset from the normal prose in a manner indicating a different quality of text.

Suffice it to say, it's not to be used to merely italicize something. For example, we could use it to mark up the odd name in this line of text:

<p>However, discussion on the hgroup element is now frustraneous as it's now gone the way of the <i>Raphus cucullatus</i>.</p>

Or, perhaps if you were marking up a button in a food ordering web application, you might do this:

<button type="button">
    French Fries <i>No Salt Added</i>
</button>

There are plenty of other text-level semantic tags in HTML; for the full rundown, take a look at the relevant section of the specification at the following URL: http://www.w3.org/TR/html5/text-level-semantics.html#text-level-semantics.

You have been reading a chapter from
Responsive Web Design with HTML5 and CSS - Third Edition
Published in: Apr 2020
Publisher: Packt
ISBN-13: 9781839211560
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image