Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Often, when formatting documents you're going to need to emphasize content in a specific manner. Let's take a look at a few of the ways that HTML allows us to do that. Now, I have the emphasis.htm page opened here in a browser, and you can find this in the 03_06 directory. Eventually, we'll go and edit the code for this, but I just kind of wanted to show you what we're going to be doing and to illustrate it, we are going to be working on the page that sort of explains this a little bit. We have four tags that we're going to take a closer look at.
We have the bold tag, strong tag, the italics tag, and the emphasis tag, and one of the reasons that we're going to spend time on those four tags in particular is that, one, they're probably the most common tags that you'll use to emphasis content, and also they're probably the four most confusing tags in terms of why do we have four the seemingly do the same thing. So in addition to taking a look at how we're emphasizing text and how the browser is going to render that, we're going to take a look at the meaning behind these tags as well. Now we're going to start with the bold tag.
I'm going to switch over to my code. We're going to go through some of these items and bold them using the bold tag. Now the bold tag, it's had a sort of odd history in HTML. In XHTML 1.0 it was deprecated and removed from HTML, and it was obviously available in HTML 4. The reason for that is because this was a presentational tag, meaning it did nothing to your content other than tell the user agent to display in a certain way. Let's go ahead and use it on each of these terms, these definition terms here.
I'm going to go ahead and wrap all of those terms in a bold tag. So it's just B. Opening B tag, closing B tag, and again, I'm going to do that for each one of these guys. So again, it doesn't change the meaning of this text in any way at all. All it's really doing when we do this is tell the browser, or whoever's processing this page, this text needs to be displayed in bold, and there are a couple more here that I want to do real quickly.
For example, up top, where it says the bold tag is meant to represent a span of text that you wish to set apart stylistically from the rest of text without inferring any type of special relevance or meaning, right at the end of that where it says, "browsers typically bold this text," take the word bold, I'm going to wrap that in a bold tag as well. We'll do the same thing for the strong tag, which we're going to talk about in just a moment in a little bit more detail. All of this will become clearer in just a little bit, but if we go down into the paragraph underneath all of this, then you're going to see the last paragraph here we have the word cite surrounded by a left angle and a right angle bracket.
Just to its left we have the cite tag. Go ahead and wrap the word cite outside of those parentheses in a bold tag as well. So if I save this, go back to my browser, and update the page, you can see now everywhere that we apply the bold tag, all that text is now appearing as bold. But the issue here is that it doesn't really mean anything. It doesn't change the meaning. So screen readers won't inflect the text differently. Other user agents won't denote any type of meaning from this.
It's just simply presentational. Now, contrast that with the strong tag. Now, as the text says, the strong tag, when you use it you're representing the text that's inside of it as having strong importance. Now, what that means is if someone were talking about it, for example, that would change their vocal inflection or the text itself has a little bit of a different meaning. Let's go ahead and use that. I'm going to scroll down to this paragraph right here where we sort of discuss those differences, where it says "you're probably wondering why they're multiple texts for bolding and italicizing text.
If you are, don't worry. You are not alone." So you're not alone. We want that to be very strongly emphasized. You're not alone. You know we want people to know that we're out there and we're with you. So in order to do that, we're going to surround that with a strong tag. So I'm going to do everything including the exclamation point there. So now if I save this and I go back into my browser and refresh this, we can see that you're not alone is now represented as being bold, and that's where the confusion sets in. Most people say, well, the same thing. Nothing happened.
But it's not really the same thing, and here is the easiest way to sort of denote that difference. And if you read through the paragraph, you'll kind of get this from the paragraph as well. But essentially, if you can imagine the text being formatted some other way--maybe underlined or highlighted or made a little bit larger or changed in some way--just because you want it to be strongly emphasized to the people that see it, then a bold tag is not appropriate and it should be a strong tag. On the other hand, if all you want to do is bold it and you don't care that any additional meaning is passed along-- you're just changing the formatting-- that's when you use the bold tag.
The same can be said for the italics tag and the emphasis tag. So instead of dealing with bolding text, we're dealing with italicizing it or emphasizing it. For example, I'm going to take the word italics at the end of the italic tag here and I'm going to wrap that it in an I tag. So that's italics, and I'm going to do the same thing in a paragraph here for the emphasis tag. I'm going to go ahead and right here on this line where it says "although this tag is usually rendered in italics," I am going to italicize that. Now, contrast that with the need to emphasize text.
So the em tag stands for emphasizing text. It's typically in a browser displayed as emphasis, but through the use of CSS, I can change it to whatever I want. So if I come down to this bottom paragraph, one set of tags is presentational while the other is logical. I want to emphasize the word presentational and logical to make sure that people are really paying maybe a little bit more attention to those particular words. So I'm going to take presentation and logical and I'm going to wrap them in an em tag. The same thing here for logical.
Save that and again preview it in my browser. You can see, visually it doesn't really look any different. We have italics up here, we have italics here, and then presentational and logical are displayed in italics as well. But we know that behind the scenes, structurally, there is a difference between those tags. Don't worry. If the difference between them isn't crystal clear to you at first, just research these tags as much as you can, pay attention to how authors use them as well. So look at other people's pages and code and see where they use em in place of italics or where they use italics in place of em.
Over time you're going to develop a use case for when you should use one of the elements over its counterpart.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.