HTML Blocks:
In HTML, a “block” refers to a portion of the HTML document that is treated as a single unit and typically starts on a new line. Block-level elements are used to structure the content and layout of a web page. Here are some common block-level elements in HTML:
1. <div>: The `<div>` element is a generic container that can be used to group other block-level or inline elements. It is often used for styling purposes and layout structuring.
html
<div>
<p>This is a paragraph inside a div.</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
HTML Blocks |
2. Headings `<h1>` to `<h6>`: These elements define headings of different levels. `<h1>` is the highest level, and `<h6>` is the lowest.
html
<h1>Main Heading</h1>
<h2>Subheading 1</h2>
<h3>Subheading 2</h3>
3. <p>: The `<p>` element is used to define paragraphs of text.
html
<p>This is a paragraph of text.</p>
4. <ul>, <ol>, <li>: These elements are used for creating unordered lists, ordered lists, and list items, respectively.
html
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<ol>
<li>First</li>
<li>Second</li>
</ol>
5. <table>: The `<table>` element is used to create tables.
html
<table>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</table>
6. <form>: The `<form>` element is used to create HTML forms for user input.
html
<form action=”/submit” method=”post”>
<!– form fields go here –>
<input type=”text” name=”username” placeholder=”Username”>
<input type=”password” name=”password” placeholder=”Password”>
<button type=”submit”>Submit</button>
</form>
These block-level elements create distinct blocks of content in the HTML document, and their default behavior is to start on a new line and take up the full width available. CSS can be used to further style and position these blocks on the page.