×

HTML Hide Element

The HTML hide element is used to hide the element. We place the hidden attribute inside those elements which we want to hide. The hidden attribute is a Boolean attribute.

The elements with the hidden attribute are not displayed on the web page. We can apply conditions to see the hidden element. The user can see the hidden element if the specified conditions are met.

The hidden attribute is a Global attribute. We can use hidden attribute on any HTML element.

Syntax:

<element_name hidden> some text </element>

Examples of HTML Hide Element:

Example1:

We use the hidden attribute inside the <p> tag to hide the paragraph.

<!DOCTYPE html>  
<html>  
<head>  
<title> Example 1 of Hide Element </title>  
</head>  
<body bgcolor="lightpink">  
<center>  
<h1> Hidden Element </h1>  
</center>  
<div>
<p hidden> This paragraph should be hidden. </p>  
</div>
</body>  
</html>

Output:

The output displays only the heading tag and hides the paragraph element.

HTML Hide Element

Example 2:

This example illustrates the use of hidden attribute inside the <div> element.

<!DOCTYPE html>  
<html>  
<head>  
<title> Example 2 of Hide Element </title>  
</head>  
<body bgcolor="orange">  
<center>  
<h1> Hiding the div element </h1>  
</center>  
<div hidden>
<p> This is the div element. </p>  
</div>
<p> Above is the div element, which is not visible. </p>
</body>  
</html>

Output:

The output shows heading element and paragraph element but hides <div> element because we have used hidden attribute inside <div> element.

HTML Hide Element

Example 3:

We are using hidden attribute inside the input elements labeled with first name and phone number which hide both the input fields.

<!DOCTYPE html>  
<html>  
<head>  
<title> Example 3 of Hide Element </title>  
<style>
body {  
font-family: Arial, Helvetica, sans-serif;  
background-color: olive;  
}   
.container {  
padding: 50px;  
background-color: rgb(231, 231, 164);  
}  
input[type=text] {  
  padding: 12px; 
  width: 100%;  
  border: none;  
  margin: 2px 0 20px 0;  
  background: #a3eaea;  
}  
input[type=text]:focus {  
background-color: rgb(188, 229, 242);  
outline: none;
}  
</style>
</head>  
<body bgcolor="cyan">  
<center>  
<h1> Hiding the input element of the form </h1>  
</center>  
<form class="container"> 
    <label for="fname"> First Name: </label>  <input type="text" name="firstname" value="First name" hidden>
    <br> 
    <br>
    <label for="lname"> Last Name: </label>  
    <input type="text" name="lastname" value="Last name">
    <br>
    <br>
    <label for="Email-id"> Email Id: </label> 
    <input type="text" name="Email-id" value="Email-id">
    <br>
    <br>
    <label for="employee-id"> Employee Id: </label>
    <input type="text" name="Employee-id" value="Employee-id">
    <br>
    <br>
    <label for="Gender"> Gender: </label>
    <select name="Gender">
        <option value="male"> MALE </option>
        <option value="female"> FEMALE </option>
        <option value="other"> OTHER </option>
    </select>
    <br>
    <br>
    <label for="phone"> Phone Number: </label>
    <input type="text" name="phone" value="Phone Number" hidden>
    <br>
    <br>
   <button type="submit"> SUBMIT </button>
   <button type="reset"> RESET </button>
  </form>
</body>  
</html>

Output:

As you can see, both the input elements are hidden, and only the label of both elements is visible.

HTML Hide Element

Browser Support:

It supports the following browsers:

  • Google Chrome
  • Opera
  • Mozilla Firefox
  • Internet Explorer
  • Safari

Related Topics

HTML <section> tag

The section element in HTML is used to define sections in a document. Syntax of Section Tag: <body> <h1>……….</h1> <section> <h2>……….</h2> <p> …………………………</p> </section> <section> <h2>………..</h2> <p>…………………………. <p> </section> </body> Examples of Section Tag Example 1: In this example, we use the HTML "section" element...

3 minutes read.

HTML &lt;body> alink Attribute

HTML <body> alink Attribute What is HTML? The HTML or HyperText Markup Language is used to design web pages. The file extension name for HTML file is ".html". It was released in...

2 minutes read.

HTML City tag

HTML <City> tag HTML < cite > tag specifies a citation, a reference or title to a creative work, quoted content, books, websites, a research paper, a blog post, a painting,...

3 minutes read.

HTML <summary> tag

When we simply want to show the primary heading or topic name of hidden detailed material to users, then we can achieved this by using the summary tag. This makes it...

2 minutes read.

Design a tribute page using HTML and CSS

A tribute page is a webpage based on a person who inspired us in our life. In this article, we will create a webpage of Mahatma Gandhi. We are going...

5 minutes read.

Responsive HTML5 and CSS3 Tutorial

Introduction to HTML5 Tutorial HTML5 is the latest and upgraded version of HTML. HTML is a hypertext markup language. Technically, it is not a programming language. It is a markup language. HTML...

17 minutes read.

HTML <select> tag

This tag helps in making the drop-down list on the web page. This is highly used in HTML forms for taking the input from user. You can use the id attribute...

3 minutes read.

How to append HTML code to a div using JavaScript?

In HTML, we have a div tag which is used to create a box where we can put a lot of other tags. So it works like a container. So,...

4 minutes read.

HTML Frames

Frames in Html is used to divide the browser into different sections where each section can load different Html documents. Collection of frame is known as Frameset. Creating frames:We use frameset...

2 minutes read.

HTML <table> tag

The Table element If we want to show the data and information in a two-dimensional table with rows and columns, then we can achieve this by using the HTML element <table>. Syntax: <body> <table> <thead> <tr> <thcolspan="#">………….</th> </tr> </thead> <tbody> <tr> <td>……….</td> <td>……….</td> </tr> </tbody> </table> </body> Example: <!DOCTYPE...

9 minutes read.

HTML <svg> tag

SVG is used to determine the vector-based graphics in XML format. What is SVG? We utilize SVG tag to specify visuals for the website. The attribute of SVG in a HTML document...

2 minutes read.

HTML 5 Tutorial

What is HTML5? HTML5 is a programming language which stands for the acronym Hyper Text Markup Language 5. It is program that enables the appearance of web pages to be changed, as well as changes...

5 minutes read.

HTML <u> tag

Underline Element/Tag: The u tag in html is used to specify the important text or phrase by underline. In earlier HTML versions, this element was known as the "Underline" element, and...

5 minutes read.

HTML Elements

An HTML element is nothing but a starting tag and then some content and then the closing tag. So we can say HTML elements is everything from the starting tag...

3 minutes read.

How to change font in HTML

To give style to the content of your website, you may change the font of the text and make your website look attractive to the user. There are several methods which...

4 minutes read.

HTML Basic Tags

Heading Tags: This tag represents the document header. It is said to be a good practice if every document starts with Heading. Heading tags ranges from H1 to H6 i.e....

3 minutes read.

HTML Code Tag

The code tag in HTML is a phrase tag used to insert a piece of computer programming code. In HTML there is a separate tag named as <code> tag. Sometimes,...

3 minutes read.

Most Commonly used Tags in HTML

In this tutorial, we'll look at the most popular HTML tags. We know HTML is a fundamental requirement for creating a website. As a result, it is essential to remember...

9 minutes read.

HTML <source> tag

For media attributes, such as <video> tag, <audio> tag, and <picture> tag, we use the <source> tag in html for adding such type of multiple media html elements in our...

4 minutes read.

HTML Date

The input element in HTML has several attributes. One of its attributes is the type attribute which creates a calendar in an order that a user can select a date...

5 minutes read.