Add the style
attribute to the element you want to hide.
<p style="display: none;">This text will be hidden</p>
Use the display
property and set it to none
.
p { display: none; }
You can also use JavaScript to hide elements. Here’s an example:
document.getElementById("element-id").style.display = "none";
Note that the element will still be in the HTML code, but it will not be visible on the page. If you want to completely remove the element from the HTML, you can use the removeChild()
method in JavaScript.
var element = document.getElementById("element-id"); element.parentNode.removeChild(element);