×

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

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.

Html Wbr Tag

The Line Break Opportunity element A word break opportunity is a place in text from where the browser breaks a line. This opportunity is represented by the element wbr in the...

2 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 Unordered List

In HTML, we have <ul> tag which defines the unordered list. And it is also known as bulleted list, because as we know it is not ordered list therefore it...

2 minutes read.

HTML <samp> tag

The Samp tag in HTML is used for defining the sample output from the computer program. This tag is a phrase type tag and a container tag that means the...

2 minutes read.

HTML Canvas

HTML Canvas: Using JavaScript, the < canvas > tag in HTML is used for drawing graphics on web page. It can be used to draw routes, boxes, text, gradient, and...

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

HTML <br> tag

HTML is referred to as Hyper Text Markup Language, which is the most popular language for creating Web pages. HTML explains the construction of a Web page. It contains a...

4 minutes read.

HTML <sup> Tag

The HTML sup element is used to describe one or more superscript contents. The sup tag shows a text which is presented above the regular line and half the length...

2 minutes read.

HTML <style> tag

The section of information that we want to style is contained in html style tag. It includes CSS, which is used to design the text and images in the web page. Syntax: <head> <title>…………....

3 minutes read.

How to change text color in HTML

Changing the text colour of a web page is essential because it enhances readability. There are several ways to change the colour of the text in HTML, which are as follows: Text...

7 minutes read.

HTML Event Attributes

HTML Event Attributes If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on...

4 minutes read.

HTML <video> Tag

The Video tag in HTML is used to play video on a media player on the web page. We can also insert an audio by the video tag, but audio...

6 minutes read.

HTML <body> tag

HTML means Hyper Text Markup Language, which is most preferred for making Web pages. It explains how a Web page is put together. There are many different elements in HTML,...

3 minutes read.

HTML Layouts

HTML Layouts HTML templates provide a way for well-managed, well-structured responsive web pages to be organized. We could say that the HTML layout specifies how web pages can be set up....

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

The HTML <strike> tag is used to specifies strikethrough text. The tag is deprecated now and <del> tag is used in HTML files instead of it. All the global and...

2 minutes read.

HTML5 Attribute

HTML Attribute HTML attributes are special words that provide additional information about the HTML element or attributes.The element or tags have attributes, which define the element's behavior.It also adds attributes with a start...

3 minutes read.

How to add Google Translate Button on your Webpage?

Google translator is a multi-language translator used for translating the webpage. Google develops it. In today's digital age, it is essential because information is available worldwide in some specific language...

5 minutes read.