
- HTML Home
- HTML Roadmap
- HTML Introduction
- HTML History & Evolution
- HTML Editors
- HTML Basic Tags
- HTML Elements
- HTML Attributes
- HTML Headings
- HTML Paragraphs
- HTML Fonts
- HTML Blocks
- HTML Style Sheet
- HTML Formatting
- HTML Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - DOM Style Object display Property
HTML DOM Style Object display property sets or returns the display type of an element. It is similar to visibility property, but the difference is that with display:none, it hides the entire element whereas in visibility:hidden, the elements are only invisible and elements are still present on their original position.
Syntax
Set the display property:object.style.display= value;Get the display property:
object.style.display;
Property Values
Value | Description |
---|---|
inline | It is the default value which displays an element as an inline element. |
block | It displays an element as a block-level element. |
compact | It displays an element as a block-level or inline, depending on the context. |
flex | It displays an element as a block-level flex box. |
inline-block | It displays an element as a block box inside an inline box. |
inline-flex | It displays an element as an inline-level flex box. |
inline-table | It displays an element as an inline table. |
list-item | It displays an element as a list. |
marker | It is used with :before and :after CSS pseudo elements. It sets the content before or after a box to be a marker. |
none | It does not display any element. |
run-in | It displays an element as block-level or inline, depending on the context. |
table | It displays an element as a block table, with a line break before and after the table. |
table-caption | It displays an element as a table caption. |
table-cell | It displays an element as a table cell. |
table-column | It displays an element as a column of cells. |
table-column-group | It displays an element as a group of one or more columns. |
table-footer-group | It displays an element as a table footer row. |
table-header-group | It displays an element as a table header row. |
table-row | It displays an element as a table row. |
table-row-group | It displays an element as a group of one or more rows. |
initial | It is used to set this property to it's default value. |
inherit | It is used to inherit the property of it's parent element. |
Return Value
It returns a string value which represents display type of an element.
Examples of HTML DOM Style Object 'display' Property
The following examples illustrates different property values of display property.
Set Display Property
In this example we have set the display property value to 'inline' 'block' and 'none'./p>
<!DOCTYPE html> <html lang="en"> <head> <style> #display { height: 400px; width: 400px; background-color: blanchedalmond; } </style> <title> HTML DOM Style Object display Property </title> </head> <body> <p>Click to change display style</p> <button onclick="fun()">Inline</button> <button onclick="funTwo()">Block</button> <button onclick="funThree()">None</button> <br> <div id="display"> Welcome to TutorialsPoint.. </div> <script> function fun() { document.getElementById("display") .style.display = "inline"; } function funTwo() { document.getElementById("display") .style.display = "block"; } function funThree() { document.getElementById("display") .style.display = "none"; } </script> </body> </html>
Get Display Property
In this example we have used two display property value which are 'table-caption' and 'none' as well as we are getting the name of the property value used.
<!DOCTYPE html> <html lang="en"> <head> <style> #display { height: 400px; width: 400px; background-color: blanchedalmond; } </style> <title> HTML DOM Style Object display Property </title> </head> <body> <p>Click to change display style</p> <button onclick="funThree()">Table Caption</button> <button onclick="funTwo()">None</button> <br> <div id="display"> Welcome to <span id="cap">TutorialsPoint</span> </div> <p id="output"></p> <script> function funThree() { let x=document.getElementById("cap") .style.display = "table-caption"; document.getElementById("output").innerHTML=x } function funTwo() { let x=document.getElementById("display") .style.display = "none"; document.getElementById("output").innerHTML=x } </script> </body> </html>
Supported Browsers
Property | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
display | Yes 1 | Yes 12 | Yes 1 | Yes 1 | Yes 7 |
html_dom.htm
Advertisements