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.
<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.
<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.
span { color: red; }
Follow the highlighted portions of the code to input them correctly.
What is the most appropriate answer to fill in the blank?
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help