HTML Elements
HTML elements are the fundamental units that define content on a webpage, consisting of tags and the content enclosed within them.
Most HTML elements consist of a start tag
, an end tag
, and the content
in between.
<startTag>HTML Element Content</endTag>
For example, in the code below, 'Hello' enclosed in <p>
tags represents a p element
.
<p>Hello</p>
By using HTML elements, you can display various types of content such as images, videos, audio, and links on a webpage.
3 Key HTML Elements
There are hundreds of types of HTML tags, but you don't need to memorize them all.
The 3 elements introduced below are the most basic and important elements for building a webpage.
<h1> ~ <h6>
: Heading Elements
The h in h elements stands for Heading
, and they represent titles and subtitles in a document, ranging from h1 to h6 levels.
<h1>
is the most important title, while <h6>
is the least important.
<h1>Main Title</h1> <h2>Sub Title</h2> <h3>Subsection Title</h3>
<p> ~ </p>
: Paragraph Elements
The p in p elements stands for Paragraph
, and the p element defines a block of text.
<p>Paragraph</p>
<a> ~ </a>
: Anchor Elements
The a in a elements stands for anchor
, and they create links to other websites or different sections within the same webpage.
<a href="https://www.example.com">Link</a>
Besides these, elements like <div>
, <img>
, <input>
, <ul>
, <li>
, and various other HTML elements can be used to construct a webpage's content.
Parent & Child Elements
HTML elements have a hierarchical structure that involves Parent
and Child
relationships.
A Parent Element
is a higher-level element that contains other HTML elements within it. The lower-level HTML elements contained within a parent are called Child Elements
.
<!-- This div is the parent element. --> <div> <!-- This p is a child element. --> <p>Hello!</p> </div>
In the example above, the <div>
element is the parent element of the <p>
element, which is positioned as a child element under the <div>
.
Exercise
Follow and input the emphasized parts of the code.
A child element is an element contained within a parent element.
Lecture
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help