Text Content
Create readable and meaningful text using paragraphs, formatting elements, quotations and code elements.
Learn how HTML presents text, creates meaningful hyperlinks, displays images, plays audio and video, and embeds external content into web pages.
What you will learn in this level
In Level 07, you learned the basic structure of an HTML document, tags, elements, attributes, headings, paragraphs, links and images. Now we move deeper into the content that real web pages contain.
Create readable and meaningful text using paragraphs, formatting elements, quotations and code elements.
Create absolute, relative, internal, external, email and telephone links.
Use images correctly with src, alt, dimensions, figure and figcaption.
Add audio, video, multiple media sources and fallback content to a web page.
Understand iframe and the basic principles of embedding external content.
Combine text, links and media into a complete HTML learning page.
HTML describes what content means
Most web pages contain large amounts of text. HTML provides elements that allow us to organize that text into meaningful structures.
The <p> element represents a
paragraph of text.
<p>
HTML gives structure to web content.
</p>
HTML is not primarily a decoration language. It tells the browser and other tools what content represents.
Understanding <p> and <br>
A paragraph and a line break are not the same thing. A paragraph represents a block of related content. A line break simply moves the next content to a new line.
<p>
First paragraph.
</p>
<p>
Second paragraph.
</p>
<p>
CodeBhavya<br>
From Learning to Limitless Possibilities.
</p>
<br>
elements to create page spacing.
HTML should describe structure; CSS should handle visual spacing.
Visual appearance versus semantic meaning
Both may appear bold, but their meaning is different.
<b>Bold appearance</b>
<strong>
Important information
</strong>
<em> communicates emphasis,
while <i> is generally used for
alternate voice or stylistic text.
<i>Technical term</i>
<em>
Read this carefully
</em>
<mark>Important word</mark>
<small>
Additional information
</small>
<del>Old price</del>
<ins>
New price
</ins>
Learn HTML and practice every day. This is a very important concept.
Use <sub> when content should
appear below the normal text baseline.
H<sub>2</sub>O
CO<sub>2</sub>
Use <sup> for raised content.
x<sup>2</sup>
10<sup>3</sup>
Use <blockquote> for a longer
quotation.
<blockquote>
Learning never stops.
</blockquote>
<p>
The teacher said
<q>Practice every day.</q>
</p>
<p>
I am reading
<cite>HTML and CSS</cite>.
</p>
Displaying programming code correctly
Represents a fragment of computer code.
<p>
Use <code>printf()</code> in C.
</p>
Preserves spaces and line breaks.
<pre>
Line 1
Line 2
Line 3
</pre>
<pre>
and
<code>.
The <a> element connects resources
Hyperlinks are one of the foundations of the Web. They allow users to move between pages, sections, websites and other resources.
<a href="https://codebhavya.com">
Visit CodeBhavya
</a>
Understanding where a link points
about.html
A relative URL is interpreted using the location of the current document.
An absolute URL contains the complete destination, including the protocol and domain.
page.html
→ current directory
../page.html
→ parent directory
https://example.com
→ complete external address
Jump directly to a section of the same page
An internal link uses an element's
id
together with the
#
fragment syntax.
<h2 id="contact">
Contact Us
</h2>
<a href="#contact">
Go to Contact
</a>
#
must match the target element's
id.
Opening another website safely
<a
href="https://example.com"
target="_blank"
rel="noopener noreferrer"
>
Open Example
</a>
Requests that the destination open in a new browsing context, commonly a new tab.
Commonly used as a defensive security and privacy measure when opening external resources.
Contact links using mailto and tel
<a href="mailto:hello@example.com">
Email Us
</a>
When supported, the user's email application can open with the address already prepared.
<a href="tel:+919999999999">
Call Us
</a>
On supported mobile devices, tapping the link can open the phone application.
The <img> element
<img
src="images/logo.png"
alt="CodeBhavya logo"
>
Making images meaningful
<img
src="student-record.png"
alt="Student record management dashboard"
>
Describe the useful meaning of the image rather than simply writing "image" or "picture".
<img
src="decorative-line.png"
alt=""
>
An image that provides no useful information can use an empty alternative text value.
<figure>
<img
src="html-structure.png"
alt="HTML document structure"
>
<figcaption>
Basic structure of an HTML document.
</figcaption>
</figure>
Adding sound to a web page
<audio controls>
<source
src="audio/lesson.mp3"
type="audio/mpeg"
>
Your browser does not support audio.
</audio>
The controls attribute asks the browser
to display controls such as play, pause and volume.
Adding video content
<video controls width="640">
<source
src="videos/html-introduction.mp4"
type="video/mp4"
>
Your browser does not support video.
</video>
Providing multiple media alternatives
<video controls>
<source
src="lesson.webm"
type="video/webm"
>
<source
src="lesson.mp4"
type="video/mp4"
>
Your browser does not support video.
</video>
Embedding another browsing context
<iframe
src="https://example.com"
title="Example website"
width="600"
height="400"
>
</iframe>
A descriptive iframe title helps users understand what the embedded browsing context represents.
Not every external website allows itself to be displayed inside an iframe. The destination's security policies can prevent embedding.
Preparing media for different screen sizes
Use meaningful alt text for informative images.
Use suitable dimensions instead of unnecessarily huge media.
Avoid unnecessarily large image, audio and video files.
Provide useful fallback content where appropriate.
max-width,
Flexbox and Grid will be covered in the CSS levels.
Combining text, links and media
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Learning Resources</title>
</head>
<body>
<h1>HTML Learning Resources</h1>
<p>
Welcome to
<strong>CodeBhavya</strong>.
</p>
<h2>Useful Links</h2>
<a href="html-fundamentals.html">
HTML Fundamentals
</a>
<br>
<a
href="https://developer.mozilla.org/"
target="_blank"
rel="noopener noreferrer"
>
MDN Web Docs
</a>
<h2>Learning Image</h2>
<figure>
<img
src="html-structure.png"
alt="HTML document structure"
width="500"
>
<figcaption>
Basic HTML document structure.
</figcaption>
</figure>
<h2>Learning Video</h2>
<video controls width="600">
<source
src="html-basics.mp4"
type="video/mp4"
>
Your browser does not support video.
</video>
</body>
</html>
Click different parts of a URL to understand what each part means.
https://codebhavya.com/Web-Technologies/html-fundamentals.html?mode=learn#html
Build an HTML media element and inspect the generated code.
Problems beginners frequently make
Meaningful images should have useful alternative text.
Choose headings according to document hierarchy, not simply visual size.
Do not use line breaks as a replacement for CSS spacing.
Prefer descriptive link text that explains the destination.
Use target="_blank" only when it is actually useful.
Large files increase loading time and waste bandwidth.
Give embedded browsing contexts descriptive titles.
External websites may block iframe embedding.
Click a card to reveal the answer
Both can appear bold, but
<strong>
communicates importance while
<b>
is primarily presentational.
A relative URL identifies a resource relative to the location of the current document.
It provides a textual alternative that can communicate the image's useful meaning when the image cannot be displayed and to users relying on assistive technologies.
It requests that the linked resource open in a new browsing context, commonly a new tab.
It is commonly used as a defensive security and privacy measure for links opened in a new browsing context.
They group self-contained content such as an image together with its related caption.
It allows multiple media sources to be provided so the browser can select a supported format.
An iframe embeds another browsing context inside the current HTML document.
An absolute URL gives the complete destination, while a relative URL is interpreted from the current document's location.
Test your understanding
Placement-oriented HTML exercises
Create a page containing your name, education, skills, hobbies, formatted text and a quotation.
Create internal links, external links, an email link and a telephone link.
Create three figures using images, meaningful alt text and captions.
Build a page containing audio, video, multiple sources and fallback content.
Combine headings, paragraphs, formatted text, links, images, figures and media.
Create a profile page containing contact links, an image, a short biography and an embedded learning resource.
Everything important at a glance
Click a term to reveal its meaning
A connection that allows users to navigate to another resource or location.
A complete web address containing the protocol and destination.
A path interpreted relative to the current document or website location.
Text that describes the useful meaning of an image.
The part of a URL beginning with # that identifies a location within a resource.
Content such as images, audio and video presented through a web page.
Content shown when a browser cannot use the requested media or resource.
An HTML element used to embed another browsing context.
An element used to provide media resources to audio and video elements.
Build a complete HTML learning page
Build a single HTML page that represents a personal learning profile.
One main heading using
<h1>.
At least three subheadings and three paragraphs.
Bold, emphasized and highlighted content.
One quotation and one code example.
One internal link and two external links.
One email link and one telephone link.
At least two images with meaningful alt text.
One figure with figcaption.
One audio element and one video element.
One iframe with a descriptive title.
Before marking this lesson complete, make sure you can create text content, hyperlinks, images, audio, video and embedded content without referring to the examples.