How to Make Text Invisible in HTML Code

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
Image Credit: Jacob Ammentorp Lund/iStock/Getty Images

Several HTML tags come with a property called "visibility." One element that has this style is the div tag. The div tag is a container that holds text and images in a certain location on a web page. You can use this tag to hide text on a web page. Surround your blocks of text with a div tag and it is hidden from users. This is useful when you want to make a menu or dynamic page that does not show information until a user clicks a button or link.

Advertisement

Step 1

Open your web page in a text editor. This can be something simple like Notepad or more advanced HTML editors such as Notepad++ or Visual Studio.

Video of the Day

Step 2

Place a div tag in the section of the page where you want to place the text. The code below places a div tag with the visibility property set to hidden:

Advertisement

Step 3

Enter some text within the div tag. For testing purposes, enter "My Hidden Text" within the tag. Your code should look like the below:

My Hidden Text

Advertisement

Step 4

Save the file and open it with your web browser. No text is shown in the web browser even though it can be seen in the rendered code.

Video of the Day

Advertisement

Advertisement

references