
- HTML - Home
- HTML - Roadmap
- HTML - Introduction
- HTML - History & Evolution
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - Block and Inline Elements
HTML block elements are used to create the logical and semantic layout of a web page. They help to organize the content into meaningful sections and make it easier for browsers, search engines, and site visitors to understand the structure and meaning of different parts of the web page. Inline elements are used to make useful block elements, like adding anchor links.
There are various tags that you can use to create blocks, such as <div>, <p>, <table>, and so on.
All the HTML elements can be categorized into two categories:
- Block-level Elements
- Inline Elements
HTML Block-level Elements
Block-level elements start on a new line, and anything that follows them appears on the next line. These elements may contain margins to add some space before and after. These elements take up the full width of their parent elements by default; you may set their width by using the CSS width property.
List of HTML Block-level Elements
The following table has the list of all block-level elements −
Example of Block-level Elements
The following example demonstrates the block-level elements. Here, we are using one heading and two paragraphs separated by a horizontal line.
<!DOCTYPE html> <html> <head> <title>HTML Block Level Elements</title> </head> <body> <h3>HTML Block Level Elements</h3> <p> This line will appear in the next line after Heading. </p> <hr /> <p> This line will appear after Horizontal Line. </p> </body> </html>
HTML Inline Elements
Inline elements can appear within the same line and do not start a new line on their own.
List of HTML Inline Elements
The following table lists down all the inline elements −
HTML Inline Elements | ||||
---|---|---|---|---|
<a> | <abbr> | <acronym> | <b> | <bdo> |
<big> | <br> | <button> | <cite> | <code> |
<dfn> | <em> | <i> | <img> | <input> |
<kbd> | <label> | <map> | <object> | <output> |
<q> | <samp> | <script> | <select> | <small> |
<span> | <strong> | <sub > | <sup> | <textarea> |
<time> | <tt> | <var> |
Example of Inline Elements
The following example demonstrates inline elements. Here, we are making the paragraph's text bold and italic using inline emelents <b> and <i> −
<!DOCTYPE html> <html> <head> <title>HTML inline Element</title> </head> <body> <h3>Inline Elements in HTML</h3> <!-- Using <b> inline element --> <p>This <b>paragraph</b> is bold. </p> <!-- Using <i> inline element --> <p>This is an <i>italic</i> paragraph.</p> </body> </html>
Grouping Block and Inline Elements
Block-level and inline elements can be grouped using the <div> tag. The <div> tag is a block-level element that plays a big role in grouping various other HTML tags and applying CSS to groups of elements.
Example
This example demonstrates the group of elements using the div tag −
<!DOCTYPE html> <html> <head> <title>HTML div Tag</title> </head> <body> <!-- First group of tags --> <div style="background-color:yellow"> <h4>This is first group</h4> <p>Following is a list of vegetables</p> <ul> <li>Beetroot</li> <li>Ginger</li> <li>Potato</li> <li>Radish</li> </ul> </div> <!-- Second group of tags --> <div style="background-color:cyan"> <h4>This is second group</h4> <p>Following is a list of fruits</p> <ul> <li>Apple</li> <li>Banana</li> <li>Mango</li> <li>Strawberry</li> </ul> </div> </body> </html>