I am currently hiding a div based on an if statement. The method I use is, use echo out a css style of display: none
Here is what I am doing specifically:
<style>
#content{
<?php
if(condition){
echo 'display:none';
}
?>
}
</style>
<body>
<div id="content">
Foo bar
</div>
</body>
My question being, Is this a good method for a hiding a div? Is it possible that browser cache the style and therefore ignore the echo-ed out css style?
Using Php in your CSS (Cascade Style Sheet) is not “proper”,
Also, You can use Php in your HTML:
With this code, div block don’t appear, (and you don’t use it with JavaScript), You can use this for just hidden your div :