Hiding or Disabling HTML Controls - Infocodify Tutorials
Hiding or Disabling HTML Controls - Infocodify Tutorials
Ads Right
Dom Stucture
Hiding or disabling controls
Program Flow
CSS3 in Applications
Using the visibility property
Some layouts might just not work in some view ports. In this case, you might want
to complete hide controls or disable controls.
When hiding an element using the visibility property, the overall layout still
behaves as though the element is there.
<head>
<style type="text/css">
div{
height:100px;
width:100px;
border:1px solid green;
}
/*the div is present - the content is invisible*/
#div1 {
visibility:hidden;
}
</style>
</head>
<body>
<h2> visibility:hidden; - BUT THERE IS A DIV BELOW </h2>
<div id="div1">
<p>SOME TEXT TEXT</p>
</div>
</body>
With the display property, the element is not visible and the layout is not affected
by it.
https://www.infocodify.com/web/hiding-and-disabling 1/3
4/10/23, 9:45 AM Hiding or disabling HTML controls - Infocodify Tutorials
<head>
<style type="text/css">
div{
height:100px;
width:100px;
border:1px solid green;
}
/*the div doesn't effects the layout and is invisible too */
#div2 {
display:none;
}
</style>
</head>
<body>
<h2> display:none; - THERE IS NO DIV BELOW </h2>
<div id="div2">
SOME TEXT TEXT ...
</div>
</body>
<body>
<h2> DISABLED BUTTON USING disabled="disabled"</h2>
<button id="myButton" disabled="disabled">My Button</button>
</body>
https://www.infocodify.com/web/hiding-and-disabling 2/3
4/10/23, 9:45 AM Hiding or disabling HTML controls - Infocodify Tutorials
<head>
<style type="text/css">
div{
height:100px;
width:100px;
border:1px solid green;
}
/*the div doesn't effects the layout and is invisible too */
#div2 {
display:none;
}
</style>
</head>
<body>
<h2> DISABLED BUTTON USING jQuery</h2>
<button id="myButton" class="disableIt">My Button</button>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></
<script type="text/javascript">
$("document").ready(function (e) {
$(".disableIt").attr("disabled", "disabled");
});
</script>
</body>
Previous Next
https://www.infocodify.com/web/hiding-and-disabling 3/3