HTML Block and Inline Elements
In HTML, elements are categorized as either block-level elements or inline elements. These categories describe how elements behave in terms of layout and how they interact with other elements on the page.
Block-level elements:
A block-level element always starts on a new line, and the browsers automatically add some space (a margin) before and after the element.
A block-level element always takes up the full width available (stretches out to the left and right as far as it can).
Two commonly used block elements are:
<p>
and <div>
.
The
<p>
element defines a paragraph in an HTML document.
The
<div>
element defines a division or a section in an HTML document.
Here are the block-level elements in HTML:
<address> <article> <aside> <blockquote> <canvas> <dd>
<div> <dl> <dt> <fieldset> <figcaption> <figure>
<footer> <form> <h1>-<h6><header> <hr> <li>
<main> <nav> <noscript> <ol> <p> <pre>
<section> <table> <tfoot> <ul> <video>
Example
<div>: A generic container used to group other elements. <p>: Represents a paragraph. <h1> to <h6>: Heading elements. <ul>, <ol>, <li>: List elements. <table>, <tr>, <td>: Table-related elements. <form>: Represents an HTML form.