I want to hide a section of HTML, and stop it being viewable from the webpage itself without removing it. Is this possible in HTML or CSS, or can anyone recommend a Javascript library capable of doing this? The part that needs hiding looks similar to this:
<p>text1<strong>text2</strong></p>
I don't want it to display on the website but I do want it viewable when looking at the code directly.
Any ideas?
To hide an element, set the style display property to “none”. document.
Completely hiding elements can be done in 3 ways: via the CSS property display , e.g. display: none; via the CSS property visibility , e.g. visibility: hidden; via the HTML5 attribute hidden , e.g. <span hidden>
The following style rule hides an element on a web page: display: none; When you set the value of display to none, the affected element will disappear. This means the element will no longer take up any space on the web page.
You simply can't. Code inspectors are designed for debugging HTML and JavaScript. They do so by showing the live DOM object of the web page. That means it reveals HTML code of everything you see on the page, even if they're generated by JavaScript.
Add a "hidden" class to select the target HTML and use display: none
in CSS:
HTML:
<p class="hidden">text1<strong>text2</strong></p>
CSS:
.hidden {
display: none;
}
...or you could inline it directly:
<p style="display:none">text1<strong>text2</strong></p>
You can use css display:none
<p style="display: none;">text1<strong>text2</strong></p>
There's a visibility property in CSS: http://www.w3schools.com/cssref/pr_class_visibility.asp
You could wrap whatever elements you want hidden in a <div>
and set it's visibility to hidden. This property can also be changed dynamically with Javascript.
You could also look into using jQuery, which has animated hide()
and show()
functions
I'm not sure what exactly you need, but you can try commenting it out, like:
<!--<p>text1<strong>text2</strong></p>-->
Or, add a class/id then select it and on css:
.myhidden{
display: none;
}
<p class="myhidden">text1<strong>text2</strong></p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With