How to Make Text Invisible in HTML Code

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.

Woman at sidewalk cafe reading emails
credit: Jacob Ammentorp Lund/iStock/Getty Images

Step

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.

Step

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:

Step

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

Step

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.