From the course: Crafting Meaningful HTML
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
When to use div and span elements - HTML Tutorial
From the course: Crafting Meaningful HTML
When to use div and span elements
- (Narrator) Div and span, have no semantic meaning by themselves. Although it seems like everyone turns to these elements as some of their first choices in marking up a document. Div and span should be used, only when there's no other element available to convey meaning, or when the purpose of the element, is to hold a CSS class or in some way to group together other elements on a page. So let's see some examples of that in action. So once again, here I am in code pen. And I've given you a very simple example, here we have three paragraphs, there they are. We also have a little bit of CSS down here. I've already put in some classes for a class of warning, which will give things a red background with white letters. Also created a class of bold and a class of italic. So for example, let's just say that these three paragraphs are some kind of warning that we want to draw attention to on our web page. And we want to do that, making them red backgrounds, and white letters and so forth…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Move your code from CodePen to Visual Studio Code (VS Code)2m 53s
-
(Locked)
Understand the head code4m 21s
-
(Locked)
Add semantic navigation5m 23s
-
(Locked)
Add images, figures, and figure captions5m 59s
-
(Locked)
Add footers with address, time, and date9m 13s
-
(Locked)
Add quotes, line breaks, and citations6m 11s
-
(Locked)
When to use div and span elements4m 55s
-
(Locked)
Challenge: Identify semantic problems1m 4s
-
(Locked)
Solution: Identify semantic problems5m 43s
-
-
-