Lecture

div, span Tags

The div and span tags wrap HTML elements to structure a webpage.


div (division)

Used to separate or group different parts of a webpage.

Being a block-level element, it takes up the full width of the screen by default, starting and ending on a new line.

Example of a div element
<div> <p>Paragraph inside a div element</p> </div>

span

Used to select or apply styles to a part of the text or inline elements.

As an inline-level element, it appears in the flow of text without starting a new line, only occupying the width necessary for its content.

Example of a span element
<p>This is a sentence inside a <span>span element</span>.</p>

Note that div and span themselves do not have visual style or function.

Instead, they are used with CSS (styling) or JavaScript (behavior) to style or add behavior to specific parts of the content.

For example, you can use the following CSS to change the text color within a span element to red.

Applying style to a span element
span { color: red; }

Follow the highlighted portions of the code to input them correctly.

Mission
0 / 1

What is the most appropriate answer to fill in the blank?

The div tag is a element, taking up the full width of the screen and starting on a new line.
block-level
inline-level
embedded-level
nested-level

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help

HTML
CSS
Loading...