Careeroza
Block & Inline
Block-level Elements
Example
A block-level element always starts on a new line and takes the full width available (the coloured backgrounds show the width):
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div style="background:#d0ebff">A div is block-level</div>
<p style="background:#d3f9d8">A paragraph is block-level</p>
<h3 style="background:#ffe8cc">A heading is block-level</h3>
</body>
</html>Result
Block elements: <div>, <p>, <h1>–<h6>, <ul>, <ol>, <table>, <form>, <header>, <section>...
Inline Elements
Example
An inline element does not start on a new line and only takes as much width as necessary:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p>This is <span style="background:#ffe066">a span</span>, this is <a href="#">a link</a>, and this is <b style="background:#d0ebff">bold</b>, all on one line.</p>
</body>
</html>Result
Inline elements: <span>, <a>, <img>, <b>, <strong>, <em>, <code>, <input>, <label>...
Note: An inline element should not contain a block-level element. CSS display can change how any element behaves.