Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
How To Dynamically Display and Hide HTML Elements Using Style Sheet Properties
Article ID: 199243 - View products that this article applies to.
This article was previously published under Q199243
Internet Explorer 4.0 and above provide a rich set of programming features to Web authors through Dynamic HTML (DHTML) scripting and its support of Cascading Style Sheets. This article shows how to script the display and visibility stylesheet properties to dynamically display or hide elements on the page.
Each example shows the use of the visibility and display style properties. The difference between the two properties when hiding text is that display=none does not reserve space for the object on the screen whereas visibility=hidden preserves the space used by the element but does not render the object to the screen.
Also, the display properties inline and block were not supported in Internet Explorer 4.x, but using these values still displays the elements as usual. With Internet Explorer 5, you should set the appropriate display property value based on whether the element is an inline or block element. Block elements typically start a new line and inline elements do not.
Documentation about Cascading Style Sheets and DHTML:
Information about the scripting languages can be found at the following URL:
Article ID: 199243 - Last Review: April 28, 2012 - Revision: 2.0