Select the product you need help with
How To Dynamically Display and Hide HTML Elements Using Style Sheet PropertiesArticle ID: 199243 - View products that this article applies to. This article was previously published under Q199243 SUMMARY
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.
MORE INFORMATION
The following sample code demonstrates how to display or hide text inside a P tag using the two stylesheet properties. Save the following HTML code to your desktop as dhtmtest.htm and then open it in Internet Explorer 4.0 or higher. You will see two table columns demonstrating how to display and hide text by toggling stylesheet properties with JavaScript.
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. http://msdn.microsoft.com/en-us/library/aa141508(v=office.10).aspx
(http://msdn.microsoft.com/en-us/library/aa141508(v=office.10).aspx)
Information about the scripting languages can be found at the following URL: http://msdn2.microsoft.com/en-us/library/ms950396.aspx
(http://msdn2.microsoft.com/en-us/library/ms950396.aspx)
PropertiesArticle ID: 199243 - Last Review: April 28, 2012 - Revision: 2.0
| Article Translations
|



Back to the top








