DEV Community

Ranjith srt
Ranjith srt

Posted on

MERN - Html (Day 7)

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.

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description


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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>&copy; 2025 My Website. All Rights Reserved.</p>
    <nav>
        <a href="#">Privacy Policy</a> | <a href="#">Terms of Use</a>
    </nav>
</footer>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… Key Points:

  • The datetime attribute 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… Key Points:

  • Use controls to 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>

Enter fullscreen mode Exit fullscreen mode

โœ… Key Points:

  • Use controls for 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… Key Points:

  • Items are numbered automatically (1, 2, 3โ€ฆ).
  • You can change the numbering style using the type attribute:

    
    <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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… Key Points:

  • <table> is the main container.
  • The border attribute 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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">

Enter fullscreen mode Exit fullscreen mode

โœ… Key Points:

  • for="email" should match id="email".

๐Ÿ“ <input> - Input Field

โœ… Definition: A single-line user input field.

โœ… Usage: Used for text, numbers, passwords, etc.

๐Ÿ”น Example:


<input type="text" name="username">

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… Key Points:

  • rows and cols control 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… Key Points:

  • value="50" shows progress out of max="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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… 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>

Enter fullscreen mode Exit fullscreen mode

โœ… Key Points:

  • <details> and <summary> create an interactive expandable section.
  • <dialog> is used for popup messages.
  1. 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>

Enter fullscreen mode Exit fullscreen mode

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>

Enter fullscreen mode Exit fullscreen mode

  1. <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>

Enter fullscreen mode Exit fullscreen mode

  1. <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>

Enter fullscreen mode Exit fullscreen mode

  1. HTML Entities & Symbols

Definition:

HTML entities are special codes used to display reserved or special characters in HTML.

Common Entities:

Entity Code Symbol
&copy; ยฉ
&trade; โ„ข
&reg; ยฎ
&lt; <
&gt; >
&amp; &

Example:

<p>&copy; 2025 YourWebsite &trade; &reg; </p>

Enter fullscreen mode Exit fullscreen mode

Emojis:

Emoji Code Emoji
&#x1F60A; ๐Ÿ˜Š
&#x1F44B; ๐Ÿ‘‹
&#x1F604; ๐Ÿ˜„
<p>Hello! &#x1F44B; Welcome to my site! ๐Ÿ˜Š</p>

Enter fullscreen mode Exit fullscreen mode

  1. HTML File Paths

Definition:

File paths specify the location of files in a website.

Types of File Paths:

  1. Relative Path: References files within the same directory.
  2. Absolute Path: References files using a full URL.
  3. Root-relative Path: Starts from the root directory (/).

Examples:

Relative Path:

<img src="./photo.jpg" alt="Sample" width="300px" />

Enter fullscreen mode Exit fullscreen mode

Absolute Path:

<img src="https://example.com/image.jpg" alt="Sample" width="300px" />

Enter fullscreen mode Exit fullscreen mode

Root-relative Path:

<img src="/images/sample.jpg" alt="Sample" width="300px" />

Enter fullscreen mode Exit fullscreen mode

  1. 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" />

Enter fullscreen mode Exit fullscreen mode

  1. 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>

Enter fullscreen mode Exit fullscreen mode

Why Use UTF-8?

  • It supports all languages and special characters.
  • It prevents display issues with non-English characters.

Top comments (0)