Text-Level Semantic Tags | Grouping and Media Semantic Tags | List Semantic Tags | Table Semantic Tags | Form Semantic Tags | Other Semantic Tags
img path | Marquee | entities | symbols | emojis
HTML Semantic Tags
Semantic tags give meaning to the content inside them. They help both search engines and developers understand the structure of a webpage.
1. Structural Semantic Tags
These tags define the layout of a webpage.
๐ <header> - Website Header
โ Definition: Represents the top section of a page or a section.
โ Usage: Usually contains logos, navigation menus, and headings.
๐น Example:
<header>
<h1>My Website</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
โ Key Points:
- Can be used multiple times in a page (inside
<article>or<section>).
- Usually contains branding, logo, and navigation links.
๐ <nav> - Navigation Links
โ Definition: Represents the navigation menu of a webpage.
โ Usage: Used to group important links like Home, About, Contact.
๐น Example:
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
โ Key Points:
- Used for menus, sidebars, or footer links.
- Should only contain important navigation links.
๐ <main> - Main Content Area
โ Definition: Represents the main content of the webpage.
โ Usage: Contains the most important information (not repeated in other sections like header or footer).
๐น Example:
<main>
<h2>Welcome to My Website</h2>
<p>This website shares useful programming tutorials.</p>
</main>
โ Key Points:
-
Each webpage should have only one
<main>tag. - Should not contain
<header>,<footer>,<nav>.
๐ <article> - Independent Content
โ Definition: Represents a self-contained, independent piece of content.
โ Usage: Used for blog posts, news articles, or product descriptions.
๐น Example:
html
CopyEdit
<article>
<h2>Learn HTML Semantic Tags</h2>
<p>HTML has semantic tags that give meaning to content...</p>
</article>
โ Key Points:
- Can contain title, text, images, and links.
- Each
<article>should make sense even if taken out of the page.
๐ <section> - Thematic Section
โ Definition: Represents a section inside a webpage that groups related content.
โ Usage: Used for different sections like services, testimonials, or features.
๐น Example:
<section>
<h2>Our Services</h2>
<p>We offer web development, design, and SEO services.</p>
</section>
โ Key Points:
- Should always have a heading (
<h2>,<h3>). - Used for grouping related content.
๐ <aside> - Sidebar Content]
โ Definition: Represents side content like ads, links, or related articles.
โ Usage: Used for sidebars, advertisements, and related links.
๐น Example:
<aside>
<h3>Related Articles</h3>
<ul>
<li><a href="#">HTML Basics</a></li>
<li><a href="#">CSS Flexbox</a></li>
<li><a href="#">JavaScript DOM</a></li>
</ul>
</aside>
โ Key Points:
- Not part of the main content.
- Placed beside articles or main sections.
๐ <footer> - Bottom Section
โ Definition: Represents the bottom section of a webpage.
โ Usage: Used for copyright info, contact details, or social media links.
๐น Example:
<footer>
<p>© 2025 My Website. All Rights Reserved.</p>
<nav>
<a href="#">Privacy Policy</a> | <a href="#">Terms of Use</a>
</nav>
</footer>
โ Key Points:
- Used once per page (usually).
- Contains useful links, copyright, and credits.
๐ Summary of Structural Semantic Tags
| Tag | Meaning | Use Case |
|---|---|---|
<header> |
Top section of a page | Logo, navigation, welcome text |
<nav> |
Navigation links section | Menus, sidebar links |
<main> |
Main content of page | Articles, blog posts |
<article> |
Independent content block | Blog posts, news |
<section> |
Thematic section | Grouping related content |
<aside> |
Sidebar content | Ads, related links |
<footer> |
Bottom section | Copyright, contact info |
2. Text-Level Semantic Tags
These tags help format and structure text properly to give it meaning. They are useful for SEO, readability, and accessibility.
๐ <h1> to <h6> - Headings
โ
Definition: Used for headings in a document, where <h1> is the most important and <h6> is the least important.
โ Usage: Used to structure the document into sections.
๐น Example:
<h1>Main Heading</h1>
<h2>Subheading</h2>
<h3>Smaller Subheading</h3>
โ Key Points:
- There should be only one
<h1>per page. - Helps with SEO (Search Engine Optimization).
- Do not use
<h1>just for big text; use CSS for styling.
๐ <p> - Paragraph
โ Definition: Used to write a paragraph of text.
โ Usage: Used for normal content inside a webpage.
๐น Example:
<p>This is a paragraph. HTML makes it easy to structure content.</p>
โ Key Points:
- Browsers automatically add space before and after
<p>. - Do not use multiple
<br>tags for spacing.
๐ <blockquote> - Quoting a Block of Text
โ Definition: Used to quote long text from another source.
โ Usage: Often used for citing references or articles.
๐น Example:
<blockquote>
"The only limit to our realization of tomorrow is our doubts of today."
</blockquote>
โ Key Points:
- Browsers indent
<blockquote>by default.
- Use <cite> inside it to give source information.
๐ <cite> - Citing a Source
โ Definition: Used to cite the title of a book, article, or work.
โ Usage: Helps indicate the author or reference.
๐น Example:
<p><cite>The Great Gatsby</cite> is a novel by F. Scott Fitzgerald.</p>
โ Key Points:
- It is usually displayed in italics.
๐ <q> - Short Inline Quote
โ Definition: Used to add short inline quotes.
โ Usage: Used for quoting words inside a sentence.
๐น Example:
<p>As Albert Einstein said, <q>Imagination is more important than knowledge.</q></p>
โ Key Points:
- Browsers automatically add quotation marks around
<q>.
๐ <time> - Representing Date and Time
โ Definition: Defines a specific time, date, or duration.
โ Usage: Useful for events, articles, or schedules.
๐น Example:
<p>Our meeting is scheduled for <time datetime="2025-03-30T10:00">March 30 at 10 AM</time>.</p>
โ Key Points:
- The
datetimeattribute makes it machine-readable.
๐ <address> - Contact Information
โ Definition: Used to represent contact details like email or physical address.
โ
Usage: Often used inside <footer>.
๐น Example:
<address>
Contact us at: <a href="mailto:info@example.com">info@example.com</a>
</address>
โ Key Points:
- Usually contains emails, phone numbers, or physical addresses.
๐ <pre> - Preformatted Text
โ Definition: Displays text exactly as written in the code, including spaces and line breaks.
โ Usage: Used for code blocks, ASCII art, or poems.
๐น Example:
<pre>
This text
is displayed
exactly as it is
</pre>
โ Key Points:
- Maintains spaces and line breaks.
๐ <code> - Inline Code
โ Definition: Used to display inline programming code.
โ Usage: Helps show code snippets in a readable format.
๐น Example:
<p>To print in Python, use <code>print("Hello, World!")</code>.</p>
โ Key Points:
- Does not apply any syntax highlighting.
- Use
<pre><code>for longer code blocks.
๐ <kbd> - Keyboard Input
โ Definition: Represents keyboard input (like key presses).
โ Usage: Used for computer tutorials.
๐น Example:
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy text.</p>
โ Key Points:
- Useful for shortcut key instructions.
๐ <samp> - Sample Output
โ Definition: Represents output from a computer program.
โ Usage: Used for displaying command-line results.
๐น Example:
<p>The output is: <samp>Operation completed successfully</samp></p>
โ Key Points:
- Often used with
<code>.
๐ <var> - Variable in Programming
โ Definition: Used to define a variable in programming or math.
โ Usage: Used in math equations or coding tutorials.
๐น Example:
<p>The formula for area is <var>ฯrยฒ</var></p>
โ Key Points:
- Usually displayed in italics.
๐ <abbr> - Abbreviation
โ Definition: Represents an abbreviation or acronym.
โ Usage: Shows full meaning when hovered.
๐น Example:
<p><abbr title="HyperText Markup Language">HTML</abbr> is a markup language.</p>
โ Key Points:
- Helps with accessibility and SEO.
๐ <strong> - Important Text
โ Definition: Represents strong importance (bold by default).
โ Usage: Highlights critical words in a sentence.
๐น Example:
<p><strong>Warning:</strong> Do not touch the wires.</p>
โ Key Points:
- Use for important warnings or notices.
๐ <em> - Emphasized Text
โ Definition: Used for emphasizing words (italic by default).
โ Usage: Adds stress to words.
๐น Example:
<p>This is <em>very important</em> information.</p>
โ Key Points:
- Improves voice inflection for screen readers.
๐ <mark> - Highlighted Text
โ Definition: Highlights important text (yellow by default).
โ Usage: Used to grab attention.
๐น Example:
<p>Please <mark>read this carefully</mark> before proceeding.</p>
โ Key Points:
- Used for important highlights.
๐ <del> - Deleted Text
โ Definition: Shows deleted text with a strike-through.
โ Usage: Used for corrections or edits.
๐น Example:
<p>This was <del>wrong</del> correct.</p>
โ Key Points:
- Shows content that was removed.
๐ <ins> - Inserted Text
โ Definition: Shows added text with an underline.
โ Usage: Used to show updates or edits.
๐น Example:
<p>This is <ins>newly added</ins> content.</p>
โ Key Points:
- Helps track changes in content.
3. Grouping & Media Semantic Tags
These tags group related content and handle multimedia like images, videos, and audio. They improve SEO, readability, and accessibility.
๐ <figure> - Self-contained Content (Image/Chart/Code Snippets)
โ Definition: Groups images, charts, code snippets, or diagrams with a caption.
โ Usage: Helps associate an image with its description.
๐น Example:
<figure>
<img src="nature.jpg" alt="Beautiful Nature">
<figcaption>Nature is always beautiful.</figcaption>
</figure>
โ Key Points:
-
<figcaption>is optional and provides a caption. - Improves SEO and screen reader accessibility.
๐ <figcaption> - Caption for <figure>
โ
Definition: Provides a description or title for content inside <figure>.
โ
Usage: Used inside <figure> to describe the content.
๐น Example:
<figure>
<img src="car.jpg" alt="A red sports car">
<figcaption>A stylish red sports car.</figcaption>
</figure>
โ Key Points:
- Always use it inside
<figure>.
๐ <picture> - Responsive Images
โ Definition: Helps display different images for different screen sizes.
โ Usage: Used for responsive design.
๐น Example:
<picture>
<source srcset="small.jpg" media="(max-width: 600px)">
<source srcset="large.jpg" media="(min-width: 601px)">
<img src="default.jpg" alt="Default Image">
</picture>
โ Key Points:
-
<source>chooses the best image based on screen size. - Always include a fallback
<img>.
๐ <audio> - Embedding Audio
โ Definition: Embeds audio files in a webpage.
โ Usage: Used for background music, podcasts, or sound effects.
๐น Example:
<audio controls>
<source src="music.mp3" type="audio/mpeg">
<source src="music.ogg" type="audio/ogg">
Your browser does not support audio.
</audio>
โ Key Points:
- Use
controlsto add play, pause, and volume buttons. - Always provide multiple formats (
.mp3,.ogg).
๐ <video> - Embedding Video
โ Definition: Embeds video files in a webpage.
โ Usage: Used for tutorials, clips, or background videos.
๐น Example:
<video width="320" height="240" controls>
<source src="video.mp4" type="video/mp4">
<source src="video.ogg" type="video/ogg">
Your browser does not support video.
</video>
โ Key Points:
- Use
controlsfor play/pause buttons. - Add multiple formats for better support.
๐ <source> - Alternative Media Sources
โ
Definition: Provides alternative media sources for <picture>, <audio>, and <video>.
โ
Usage: Used inside <picture>, <audio>, or <video> to support different file types.
๐น Example:
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
<source src="audio.ogg" type="audio/ogg">
</audio>
โ Key Points:
- Helps provide backup formats for media.
๐ <track> - Subtitles and Captions for Video
โ
Definition: Adds subtitles, captions, or descriptions to <video>.
โ Usage: Improves accessibility for deaf users.
๐น Example:
<video controls>
<source src="movie.mp4" type="video/mp4">
<track src="subtitles.vtt" kind="subtitles" srclang="en" label="English">
</video>
โ Key Points:
-
kind="subtitles"specifies that it's a subtitle file. -
Use
.vtt(WebVTT format) for subtitles.
4. List Semantic Tags
Lists are used to organize content in an ordered or unordered way. They help with readability, structure, and accessibility.
๐ <ul> - Unordered List
โ Definition: Creates a bulleted list.
โ Usage: Used when the order of items does not matter.
๐น Example:
<ul>
<li>Apples</li>
<li>Bananas</li>
<li>Oranges</li>
</ul>
โ Key Points:
- Each item in the list is inside
<li>(list item). - Browser automatically adds bullets.
๐ <ol> - Ordered List
โ Definition: Creates a numbered list.
โ Usage: Used when the order of items matters (like steps or rankings).
๐น Example:
<ol>
<li>Wake up</li>
<li>Brush your teeth</li>
<li>Have breakfast</li>
</ol>
โ Key Points:
- Items are numbered automatically (1, 2, 3โฆ).
-
You can change the numbering style using the
typeattribute:
<ol type="A"> <li>Item 1</li> <li>Item 2</li> </ol>โ Output: A. Item 1, B. Item 2โฆ
๐ <li> - List Item
โ
Definition: Represents a single item in <ul> or <ol>.
โ
Usage: Used inside unordered (<ul>) or ordered (<ol>) lists.
๐น Example:
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
โ Key Points:
- Must always be inside
<ul>or<ol>.
๐ <dl> - Description List
โ Definition: Creates a list of terms and descriptions.
โ Usage: Used for glossaries, FAQs, or key-value pairs.
๐น Example:
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
โ Key Points:
-
<dt>= Term (word or phrase) -
<dd>= Description (explanation of the term)
๐ <dt> - Definition Term
โ Definition: Represents the term (title or keyword) in a description list.
โ
Usage: Used inside <dl> before <dd>.
๐น Example:
<dt>Python</dt>
<dd>A popular programming language.</dd>
โ Key Points:
- Must be inside
<dl>.
๐ <dd> - Definition Description
โ Definition: Represents the description or explanation of a term.
โ
Usage: Used after <dt>.
๐น Example:
<dl>
<dt>JavaScript</dt>
<dd>A language used for web development.</dd>
</dl>
โ Key Points:
- Must be inside
<dl>after<dt>.
๐ Comparison of List Types
| Tag | Type of List | Uses |
|---|---|---|
<ul> |
Unordered (bullets) | Shopping lists, menus |
<ol> |
Ordered (numbers) | Steps, rankings, instructions |
<dl> |
Description list | Glossaries, FAQs |
5. Table Semantic Tags
Tables are used to organize data in rows and columns. They are useful for reports, pricing tables, and structured content.
๐ <table> - Table Container
โ Definition: Defines a table in HTML.
โ Usage: Used to display tabular data.
๐น Example:
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
</tr>
</table>
โ Key Points:
-
<table>is the main container. - The
borderattribute adds a visible border (for learning). -
<tr>(table row),<th>(header cell), and<td>(data cell) are used inside.
๐ <thead> - Table Header Section
โ Definition: Groups the header rows of a table.
โ Usage: Used to separate headers from data.
๐น Example:
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
<td>22</td>
</tr>
</tbody>
</table>
โ Key Points:
- Helps organize the table structure.
- Works with
<tbody>and<tfoot>.
๐ <tbody> - Table Body Section
โ Definition: Groups the main data of the table.
โ Usage: Used to separate table content from headers/footers.
๐น Example:
<tbody>
<tr>
<td>Bob</td>
<td>30</td>
</tr>
</tbody>
โ Key Points:
- Only contains table rows (
<tr>).
๐ <tfoot> - Table Footer Section
โ Definition: Groups the footer content of a table.
โ Usage: Used for totals, summaries, or extra information.
๐น Example:
<tfoot>
<tr>
<td colspan="2">Total: 2 entries</td>
</tr>
</tfoot>
โ Key Points:
- Used for summary rows.
-
colspan="2"makes one cell span two columns.
๐ <tr> - Table Row
โ Definition: Represents a row in the table.
โ
Usage: Contains header (<th>) or data (<td>) cells.
๐น Example:
<tr>
<td>Sam</td>
<td>28</td>
</tr>
โ Key Points:
- A table must have at least one row.
๐ <td> - Table Data Cell
โ Definition: Represents a single data cell.
โ
Usage: Used inside <tr> to hold table data.
๐น Example:
<td>Emma</td>
โ Key Points:
- Used to store regular data.
๐ <th> - Table Header Cell
โ Definition: Defines a header cell.
โ
Usage: Used inside <tr> in <thead>.
๐น Example:
<th>City</th>
โ Key Points:
- Text is bold and centered by default.
๐ <caption> - Table Title
โ Definition: Adds a title to the table.
โ Usage: Describes the purpose of the table.
๐น Example:
<table border="1">
<caption>Student Information</caption>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</table>
โ Key Points:
- Always placed inside
<table>, before<tr>.
๐ Full Table Example
<table border="1">
<caption>Employee Details</caption>
<thead>
<tr>
<th>Name</th>
<th>Position</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Manager</td>
</tr>
<tr>
<td>Lisa</td>
<td>Developer</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2">Total Employees: 2</td>
</tr>
</tfoot>
</table>
โ Key Points:
- Table is well-structured (Header, Body, Footer).
-
colspan="2"spans across 2 columns.
6. Form Semantic Tags
Forms are used to collect user input like login details, search queries, or contact information.
๐ <form> - Form Container
โ Definition: The main container for user input fields.
โ Usage: Used to group all form elements.
๐น Example:
<form action="/submit" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<button type="submit">Submit</button>
</form>
โ Key Points:
-
action="/submit"โ Sends data to the server.
- method="POST" โ Sends data securely.
๐ <label> - Input Label
โ Definition: Adds a text label for an input field.
โ Usage: Helps with accessibility and usability.
๐น Example:
<label for="email">Email:</label>
<input type="email" id="email" name="email">
โ Key Points:
-
for="email"should matchid="email".
๐ <input> - Input Field
โ Definition: A single-line user input field.
โ Usage: Used for text, numbers, passwords, etc.
๐น Example:
<input type="text" name="username">
โ
Common type values:
| Type | Usage |
|---|---|
text |
Regular text input |
email |
Email validation |
password |
Hidden characters |
number |
Numeric input |
checkbox |
Multiple-choice selection |
radio |
Single-choice selection |
๐ <button> - Clickable Button
โ Definition: A clickable button.
โ Usage: Used to submit forms or trigger actions.
๐น Example:
<button type="submit">Submit</button>
โ Key Points:
-
type="submit"submits the form. -
type="button"does nothing by default.
๐ <select> - Dropdown List
โ Definition: Creates a dropdown menu.
โ Usage: Used when users select from options.
๐น Example:
<label for="country">Choose a country:</label>
<select id="country" name="country">
<option value="us">USA</option>
<option value="uk">UK</option>
</select>
โ Key Points:
-
<option>defines each choice. -
value="us"is sent to the server.
๐ <textarea> - Multi-line Textbox
โ Definition: A large input box for long text.
โ Usage: Used for comments or messages.
๐น Example:
<textarea name="message" rows="4" cols="30">Type here...</textarea>
โ Key Points:
-
rowsandcolscontrol the size.
๐ <fieldset> - Group Form Elements
โ Definition: Groups related inputs.
โ Usage: Used for better organization.
๐น Example:
<fieldset>
<legend>Personal Info</legend>
<label>Name: <input type="text"></label>
</fieldset>
โ Key Points:
- Improves form structure.
๐ <legend> - Fieldset Title
โ
Definition: Adds a title for <fieldset>.
โ Usage: Helps describe the group of inputs.
๐น Example:
<legend>Contact Details</legend>
โ Key Points:
- Always placed inside
<fieldset>.
๐ <datalist> - Auto-Suggestions
โ Definition: Provides predefined suggestions.
โ Usage: Used for quick input selection.
๐น Example:
<input list="colors">
<datalist id="colors">
<option value="Red">
<option value="Blue">
</datalist>
โ Key Points:
- Users can type or select from options.
๐ <output> - Display Calculation Results
โ Definition: Displays calculated values.
โ Usage: Used for dynamic form outputs.
๐น Example:
<output>50</output>
โ Key Points:
- Often used with JavaScript.
๐ <progress> - Progress Bar
โ Definition: Shows progress percentage.
โ Usage: Used for loading indicators.
๐น Example:
<progress value="50" max="100"></progress>
โ Key Points:
-
value="50"shows progress out ofmax="100".
๐ <meter> - Measurement Bar
โ Definition: Displays a value in a known range.
โ Usage: Used for performance levels.
๐น Example:
<meter value="7" min="0" max="10"></meter>
โ Key Points:
- Good for battery life, scores, or ratings.
๐ Full Form Example
<form action="/submit" method="POST">
<fieldset>
<legend>Signup Form</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<label for="age">Age:</label>
<input type="number" id="age" name="age">
<label for="country">Country:</label>
<select id="country" name="country">
<option value="us">USA</option>
<option value="uk">UK</option>
</select>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4"></textarea>
<button type="submit">Submit</button>
</fieldset>
</form>
โ Key Points:
- Uses multiple input types.
- Well-structured with <fieldset> and <legend>.
๐ข 7. Other Semantic Tags
These tags add meaning and functionality to content, making pages more interactive and accessible.
๐ <details> - Expandable Content
โ Definition: Creates a collapsible section.
โ Usage: Used for FAQs, extra info, or hidden content.
๐น Example:
<details>
<summary>What is HTML?</summary>
<p>HTML stands for HyperText Markup Language.</p>
</details>
โ Key Points:
-
Clicking
<summary>toggles visibility. - Can be used for FAQ sections.
๐ <summary> - Details Title
โ
Definition: Defines a clickable heading for <details>.
โ Usage: Used to describe expandable content.
๐น Example:
<summary>Click to reveal more</summary>
โ Key Points:
- Always placed inside
<details>.
๐ <dialog> - Pop-up Box
โ Definition: Creates a modal (popup) window.
โ Usage: Used for alerts, confirmations, or messages.
๐น Example:
<dialog id="myDialog">
<p>Welcome to my website!</p>
<button onclick="this.parentElement.close()">Close</button>
</dialog>
<button onclick="document.getElementById('myDialog').showModal()">Open Dialog</button>
โ Key Points:
-
showModal()โ Opens the dialog as a popup.
- close() โ Closes the popup.
๐ Full Example with All Tags
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Other Semantic Tags</title>
</head>
<body>
<h2>Expandable Content</h2>
<details>
<summary>What is JavaScript?</summary>
<p>JavaScript is a programming language for web development.</p>
</details>
<h2>Modal Dialog</h2>
<dialog id="infoDialog">
<p>This is a popup message.</p>
<button onclick="this.parentElement.close()">Close</button>
</dialog>
<button onclick="document.getElementById('infoDialog').showModal()">Open Popup</button>
</body>
</html>
โ Key Points:
-
<details>and<summary>create an interactive expandable section. -
<dialog>is used for popup messages.
- Marquee in HTML
Definition:
The <marquee> tag is used to create scrolling text or images. However, it is deprecated in HTML5. Instead, CSS animations should be used.
Attributes:
-
direction: Specifies the scroll direction (left,right,up,down). -
behavior: Defines the scrolling type (scroll,slide,alternate). -
scrollamount: Controls the speed of the scrolling. -
loop: Specifies the number of times the marquee should loop.
Example (Deprecated Method):
<marquee bgcolor="green" direction="right">Welcome to HTML</marquee>
Example (Modern CSS Method):
<div style="background-color: green; overflow: hidden">
<div class="marquee">Welcome to HTML</div>
</div>
<style>
.marquee {
width: 150px;
padding: 10px;
white-space: nowrap;
animation: scroll 10s linear infinite;
}
@keyframes scroll {
0% { transform: translateX(100%); }
100% { transform: translateX(-100%); }
}
</style>
-
<details>and<summary>
Definition:
- The
<details>tag is used to create a collapsible content section. - The
<summary>tag provides a heading for the collapsible section.
Example:
<details>
<summary>What is HTML?</summary>
<p>HTML stands for Hypertext Markup Language.</p>
</details>
-
<dialog>Tag
Definition:
The <dialog> element is used to create modal dialogs in HTML.
Example:
<button onclick="document.getElementById('modal').show()">Show Dialog</button>
<dialog id="modal">
<h3>Sample Heading</h3>
<p>This is a sample dialog box.</p>
<button onclick="document.getElementById('modal').close()">Close</button>
</dialog>
- HTML Entities & Symbols
Definition:
HTML entities are special codes used to display reserved or special characters in HTML.
Common Entities:
| Entity Code | Symbol |
|---|---|
© |
ยฉ |
™ |
โข |
® |
ยฎ |
< |
< |
> |
> |
& |
& |
Example:
<p>© 2025 YourWebsite ™ ® </p>
Emojis:
| Emoji Code | Emoji |
|---|---|
😊 |
๐ |
👋 |
๐ |
😄 |
๐ |
<p>Hello! 👋 Welcome to my site! ๐</p>
- HTML File Paths
Definition:
File paths specify the location of files in a website.
Types of File Paths:
- Relative Path: References files within the same directory.
- Absolute Path: References files using a full URL.
-
Root-relative Path: Starts from the root directory (
/).
Examples:
Relative Path:
<img src="./photo.jpg" alt="Sample" width="300px" />
Absolute Path:
<img src="https://example.com/image.jpg" alt="Sample" width="300px" />
Root-relative Path:
<img src="/images/sample.jpg" alt="Sample" width="300px" />
- HTML Image Handling
Definition:
The <img> tag is used to display images in HTML.
Attributes:
-
src: Specifies the image source. -
alt: Provides alternative text if the image fails to load. -
width&height: Set the size of the image. -
loading: Specifies lazy loading for images (lazy,eager).
Example:
<img src="https://cdn.britannica.com/34/235834-050-C5843610/cat.jpg" alt="Cat" width="300px" loading="lazy" />
- Character Sets in HTML
Definition:
A character set in HTML defines how characters are encoded and displayed in web browsers.
Common Character Sets:
| Charset | Description |
|---|---|
| UTF-8 | Universal character set (supports most languages) |
| ISO-8859-1 | Western European languages |
| ASCII | Basic English characters |
Setting Character Encoding:
The <meta charset> tag specifies the character encoding of an HTML document.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Character Encoding</title>
</head>
<body>
<p>ยฉ 2025 - Welcome to my website!</p>
</body>
</html>
Why Use UTF-8?
- It supports all languages and special characters.
- It prevents display issues with non-English characters.











Top comments (0)