5 html tags you didn't know exists
Login
Forgot Password?
Register
Forgot Password?

5 html tags you didn't know exists

Admin pcode Aug 02, 2024
5 html tags you didn't know exists
share 16 views

When diving into HTML, most of us are familiar with the basic tags: <p>, <a>, <div>, and <span>. However, HTML is a rich language with a variety of tags that are less commonly known but incredibly useful. Here, we’ll explore five HTML tags that might not be on your radar but can significantly enhance your web development skill.

1. <details> and <summary>

The <details> tag is a handy way to create interactive elements that users can expand or collapse to reveal more content. It is often used to display additional information or FAQs in a compact format.

Here’s a simple example of how it works:
html
<details>
  <summary>More Info</summary>
  <p>This is additional information that appears when the user clicks on "More Info".</p>
</details>

When rendered, users see the "More Info" text, and when they click it, the additional content within the <details> tag becomes visible. This can be particularly useful for FAQs, where users may want to expand questions to read answers without overwhelming the page with too much content at once.

2. <mark>

The <mark> tag highlights text, making it stand out from the surrounding content. It’s commonly used to emphasize search terms or important information within a block of text.

For example:

html
<p>Use the <mark>highlighted</mark> text to draw attention to important parts of your content.</p>


The text within the <mark> tag will appear highlighted, usually in a yellow or another standout color depending on the browser’s default styles. This tag is great for drawing attention to keywords or phrases that are crucial for users to notice.

3. <meter>

The <meter> tag represents a scalar measurement within a known range or a fractional value. It's often used to display a gauge or progress bar, providing users with a visual representation of how close something is to completion.

Here’s how you might use it:

html
<p>Battery level: <meter value="0.7" min="0" max="1">70%</meter></p>


In this example, the <meter> tag displays a battery level of 70%. It’s a great choice for situations where you need to show progress or a measured value, such as a user’s progress through a form or task.

4. <progress>

The <progress> tag is similar to <meter> but is specifically designed to represent the progress of a task. It is commonly used to show how much of a process has been completed.

Here’s a basic example:

html
<p>File upload progress: <progress value="45" max="100"></progress></p>

In this instance, the progress bar would show a completion level of 45%. The `<progress>` tag is useful for indicating how much of a process, like a file upload or form submission, is complete, providing users with a visual cue of their progress.

5. <template>

The <template> tag is a powerful tool for defining reusable HTML fragments that are not rendered when the page initially loads. Instead, you can use JavaScript to clone and insert these fragments into the DOM as needed.

Here’s an example of how it might be used:

html
<template id="my-template">
  <div>
    <p>This is a reusable template.</p>
  </div>
</template>


You can then use JavaScript to clone this template and insert it into the document:

Javascript
const template = document.getElementById('my-template');
const clone = document.importNode(template.content, true);
document.body.appendChild(clone);


The <template> tag is ideal for scenarios where you need to create elements dynamically based on user interaction or other conditions, making it a versatile tool for modern web development.

Exploring lesser-known HTML tags like <details>, <mark>, <meter>,<progress>, and <template> can open up new possibilities for enhancing the functionality and interactivity of your web pages. These tags not only make your code more semantic but also provide better user experiences through interactive elements and improved accessibility. Next time you’re working on a web project, consider incorporating these tags to streamline your development process and offer a richer user experience.


Stay connected