display

JavaScript syntax:

display

Values:


none | inline | block | inline-block | list-item | run-in | table | 
inline-table | table-row-group | table-header-group | tablefooter-group | 
table-row | table-column-group | table-column | 
table-cell | table-caption | inherit

Initial value:

inline

Applies to:

All elements.

Inherited:

No.

Description:

display defines the kind of display box an element generates.

Examples:

 
<head>
<style>
.style1 {
  display: none
}
</style>
<script language="JavaScript">
  function fn1() {
    item1.style.display = "";
    item2.style.display = "none";
    item3.style.display = "none";
  }
  function fn2() {
    item1.style.display = "none";
    item2.style.display = "";
    item3.style.display = "none";
  }
  function fn3_1() {
    item1.style.display = "none";
    item2.style.display = "none";
    item3.style.display = "";
  }
  function fn5() {
    item1.style.display = "";
    item2.style.display = "";
    item3.style.display = "";
  }
  function fn6() {
    item1_1.style.visibility = "visible";
    item2_1.style.visibility = "visible";
    item3_1.style.visibility = "visible";
  }
</script>
</head>
<body>
  <ul>
    <li onclick="className='style1'">Item 1 - Double-click me</li>
    <li onclick="className='style1'">Item 2</li>
    <li onclick="className='style1'">Item 3</li>
    <li onclick="className='style1'">Item 4</li>
    <li onclick="className='style1'">Item 5</li>
  </ul>
  <table border=2>
    <th>Vehicles</th>
    <th>Potency</th>
    <th>Speed</th>
    <tr id="item1">
      <td>Cars</td>
      <td id="item1_1">11111</td>
      <td>High</td>
    </tr>
    <tr id="item2">
      <td>Cycles</td>
      <td id="item2_1">123123</td>
      <td>High</td>
    </tr>
    <tr id="item3">
      <td>Bicycles</td>
      <td id="item3_1">321123</td>
      <td>Slow</td>
    </tr>
  </table>
  <p>
    <input type=button style="width: 175" onclick="fn1()" value="Show Cars"> 
    <input type=button style="width: 175" onclick="fn2()" value="Show Cycles"> 
    <input type=button style="width: 175" onclick="fn3_1()" value="Show Bicycles"> 
    <input type=button style="width: 175" onclick="fn6();fn5()" value="Reset">
</body>
  
Click here to view the demo
Home 
  HTML CSS Book 
    CSS Reference  

Property:
  1. background
  2. background-attachment
  3. background-color
  4. background-image
  5. background-position
  6. background-repeat
  7. border
  8. border-bottom
  9. border-bottom-color
  10. border-bottom-style
  11. border-bottom-width
  12. border-color
  13. border-left
  14. border-left-color
  15. border-left-style
  16. border-left-width
  17. border-right
  18. border-right-color
  19. border-right-style
  20. border-right-width
  21. border-style
  22. border-top
  23. border-top-color
  24. border-top-style
  25. border-top-width
  26. border-width
  27. bottom
  28. clear
  29. clip
  30. color
  31. content
  32. counter-increment
  33. counter-reset
  34. cursor
  35. direction
  36. display
  37. float
  38. font
  39. font-family
  40. font-size
  41. font-style
  42. font-variant
  43. font-weight
  44. height
  45. left
  46. letter-spacing
  47. line-height
  48. list-style
  49. list-style-image
  50. list-style-position
  51. list-style-type
  52. margin
  53. margin-bottom
  54. margin-left
  55. margin-right
  56. margin-top
  57. max-height
  58. max-width
  59. min-height
  60. min-width
  61. outline
  62. outline-color
  63. outline-style
  64. outline-width
  65. overflow
  66. padding
  67. padding-bottom
  68. padding-left
  69. padding-right
  70. padding-top
  71. position
  72. quotes
  73. right
  74. text-align
  75. text-decoration
  76. text-indent
  77. text-transform
  78. top
  79. unicode-bidi
  80. vertical-align
  81. visibility
  82. white-space
  83. width
  84. word-spacing
  85. z-index
Related: