Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Hide an Element - display:none or visibility:hidden?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 264
    Comment on it

    display:none:

    • An element can be hidden by setting the display property to none.
    • This property hides element in such a way that when the page will be displayed it is displayed as if the element is not there.
    • The layout is as there was no such element.
    <!DOCTYPE html>
    <html>
    <head>
    <style>
    h1.hidden {
        display: none;
    }
    </style>
    </head>
    <body>
    
    <h1>This is a visible heading</h1>
    <h1 class="hidden">This is a hidden heading</h1>
    <p>Notice that the h1 element with display: none; does not take up any space.</p>
    
    </body>
    </html>
    

    visibility:hidden:

    • An element can be hidden by setting the visibility property to hidden.
    • This property hides element in such a way that when the page will be displayed it is displayed as if the element is there i.e it takes up the same space as before.
    <!DOCTYPE html>
    <html>
    <head>
    <style>
    h1.hidden {
        visibility: hidden;
    }
    </style>
    </head>
    <body>
    
    <h1>This is a visible heading</h1>
    <h1 class="hidden">This is a hidden heading</h1>
    <p>Notice that the hidden heading still takes up space.</p>
    
    </body>
    </html>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: