Three Simple Methods for Hiding Website Content Until It’s Ready

How do you handle content that needs to be temporarily removed from a website? Maybe there is some text that gets recycled on a regular basis or something that hasn't been approved for posting yet. HTML comments could be utilized to hide everything until it's ready to go live. Just keep in mind that the content is still accessible via the browser for those who know where to look. If that's an issue, the information could be moved to a separate file and saved offline…or you could use PHP comments.

Storing Content in a Separate File

Although this may be the more cumbersome method, there are situations where it works best. If an organization has a staff page for example, entries will need to be removed as people retire, obtain employment elsewhere, etc. The information could deleted. But if someone returns, their bio information would need to be re-written and posted online again. Since it's unlikely that the people will return, it doesn't make sense to comment out the content. Instead the bios could be stored in an offline archive.

For more short-term removals, HTML comments could be used to hide the content until it's ready to be shown.

Using HTML Comments

Hiding content within the page where it will eventually be posted is beneficial since it's right where it's needed. There's no hunting down an external file for the information. With HTML comments, content is hidden by surrounding it with the comment open and close delimiters:

<!-- This text will not be displayed -->

Once ready, the comment delimiters can be removed to show the content.

The downside of using HTML comments, however, is that the content isn't technically hidden. Someone just needs to view the page's source code and locate the content of interest. If that's a concern, PHP comments might be a better fit.

Using PHP Comments

If we're announcing a highly-anticipated product, we wouldn't want those HTML comments to expose the information before the big reveal. PHP comments, on the other hand, don't get sent to the browser. Plus the hidden content is still stored in the same page where it's eventually displayed. To hide multiple lines of text, the following syntax could be used:

<?php
/*
This line of text will be hidden.
This line will also be hidden.
*/
?>

Note that there are other ways to format PHP comments. More information can be found in the PHP Manual.

Related Posts

0 Comments

There are currently no comments.

Leave a Comment