iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

HTML Block & Inline

Every HTML element has a default display mode. Block elements stack vertically and take the full width. Inline elements flow within a line of text.

The two flows

Block div, p, h1-h6, section… Inline span, a, strong, em, img…
Fig 1. Block stacks vertically; inline flows like words in a sentence.

Common elements by default mode

ModeExamples
Block<div>, <p>, <h1><h6>, <section>, <ul>, <form>
Inline<span>, <a>, <strong>, <em>, <img>, <code>
Tip: You can change an element's default mode with CSS: display: block, display: inline, or display: inline-block (which mixes both behaviors).

Example

Example
<!DOCTYPE html>
<html>
<head>
    <title>HTML Block & Inline</title>
</head>
<body>

<h1>HTML Block & Inline</h1>
<p>This is a demo page for the "HTML Block & Inline" lesson.</p>

</body>
</html>
Try it Yourself »

Exercise

Use an inline wrapper to style just a word inside a paragraph.

<p>Save < style="color: red;">$10</ > today.</p>

Test yourself

Q1. Default display of <div> is…
Q2. Default display of <span> is…
Q3. You can change display with…

Discussion

Loading…