A block-level element always starts on a new line and takes up the full width available (e.g. <div>, <p>, <h1>). An inline element does not start on a new line and only takes up as much width as necessary (e.g. <span>, <a>, <b>).
HTML Tutorial
HTML Tutorial
HTML Home
HTML Introduction
HTML Editors
HTML Basic Examples
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Text Formatting
HTML Comments
HTML Colors
HTML CSS
HTML Links & Hyperlinks
HTML Images
HTML Tables
HTML Lists
HTML Block and Inline Elements
HTML Div
HTML Classes
HTML Id Attribute
HTML Iframes
HTML JavaScript Integration
HTML Responsive Web Design
HTML Semantic Elements
HTML Graphics & Media
Advertisement
Google AdSense Slot (LEADERBOARD)
Automated High-CTR Ad Rail • Set Publisher ID in config/adsense.php
Display Model
6 min read
•
Chapter 18 of 32
HTML Block and Inline Elements
Every HTML element has a default display value, depending on what type of element it is: block or inline.
Example
<!DOCTYPE html>
<html>
<body style="font-family:sans-serif;padding:20px;">
<div style="border:2px solid blue;padding:8px;margin-bottom:8px;">Block Element (<div> takes full width)</div>
<span style="border:2px solid green;padding:4px;">Inline Element 1</span>
<span style="border:2px solid orange;padding:4px;">Inline Element 2 (Sits alongside)</span>
</body>
</html>
Try it Yourself >>
Opens live sandboxed code editor
Advertisement
Google AdSense Slot (IN-ARTICLE)
Automated High-CTR Ad Rail • Set Publisher ID in config/adsense.php
Community Q&A & Discussion
Verified
No questions yet. Be the first to start the discussion!