HTML
Elements & Tags
HTML elements are the building blocks of web pages. An element consists of a start tag, content, and an end tag. Some elements are self-closing (void elements) and don't need a closing tag.
<!-- Headings (h1 is largest, h6 is smallest) -->
<h1>Main Heading</h1>
<h2>Sub Heading</h2>
<h3>Smaller Heading</h3>
<!-- Paragraphs -->
<p>This is a paragraph of text.</p>
<!-- Links -->
<a href="https://example.com">Click here</a>
<!-- Images (self-closing) -->
<img src="photo.jpg" alt="A photo" />
<!-- Lists -->
<ul>
<li>Unordered item 1</li>
<li>Unordered item 2</li>
</ul>
<ol>
<li>Ordered item 1</li>
<li>Ordered item 2</li>
</ol>
<!-- Inline text formatting -->
<strong>Bold text</strong>
<em>Italic text</em>
<mark>Highlighted text</mark>
<code>inline code</code>
<!-- Div and span (generic containers) -->
<div>Block-level container</div>
<span>Inline container</span>
š”
Block vs Inline: Block elements like <p>, <h1>ā<h6>, <div> take up the full width and start on a new line. Inline elements like <span>, <a>, <strong> only take up as much space as their content and flow within text.
Common self-closing (void) elements:
<img />ā Images<br />ā Line break<hr />ā Horizontal rule<input />ā Form input field<meta />ā Page metadata<link />ā External resource link
Watch & Learn
A recommended video to watch alongside this chapter.
More āElements & Tagsā videos on YouTube