DONT ADD ANYTHING HERE!

  1. The visibility CSS property shows or hides an element without changing the layout of a document
  2. The property can also hide rows or columns in a table

Values

  1. visible
    The element box is visible
  2. hidden
    1. The element box is invisible (not drawn), but still affects layout as normal
    2. Descendants of the element will be visible if they have visibility set to visible
    3. The element cannot receive focus (such as when navigating through tab indexes)
  3. collapse
    The collapse keyword has different effects for different elements:
    1. For
      1. table
      2. rows
      3. colums
      4. column groups
      5. row groups
      the row(s) or column(s) are hidden and the space they would have occupied is removed
      (as if
      display: none
      were applied to the column/row of the table
      )
    2. However, the size of other rows and columns is still calculated as though the cells in the collapsed row(s) or column(s) are present
    3. This value allows for the fast removal of a row or column from a table without forcing the recalculation of widths and heights for the entire table
    4. Collapsed flex items and ruby annotations are hidden, and the space they would have occupied is removed
    5. !! For other elements, collapse is treated the same as hidden (i.e., the same as visibility:hidden, which works with (for example) a div tag)

Example

visibility:hidden

above
Hello World
below
css
.mydiv {
    visibility: hidden;
} 
html
    <div>above</div>
    <div class="mydiv">Hello World</div>
    <div>below</div>

Example

display:none

above
Hello World
below
css
        .mydiv2 {
            display: none;
        } 
html
    <div>above</div>
    <div class="mydiv2">Hello World</div>
    <div>below</div>

Example (Collapse)

  1. col {visibility: collapse}
  2. These behave different in Safari, Edge and Mozilla
visibility:visible
h1 h2 h3
d1 d2 d3
d1 d2 d3
visibility:collapse
h1 h2 h3
d1 d2 d3
d1 d2 d3
css
    .tvisible col {
        background-color: lightgoldenrodyellow;
        visibility: visible;
    }

    .tcollapse col {
        background-color: lightgoldenrodyellow;
        visibility: collapse;
    } 
html
    <table class="tvisible">
        <caption>visibility:visible</caption>
        <colgroup>
            <col>
        </colgroup>
        <tr>
            <th>h1 </th>
            <th>h2</th>
            <th>h3</th>
        </tr>
        <tr>
            <td>d1</td>
            <td>d2</td>
            <td>d3</td>
        </tr>
        <tr>
            <td>d1</td>
            <td>d2</td>
            <td>d3</td>
        </tr>
    </table>

    <table class="tcollapse">
        <caption>visibility:collapse</caption>
        <colgroup>
            <col>
        </colgroup>
        <tr>
            <th>h1 </th>
            <th>h2</th>
            <th>h3</th>
        </tr>
        <tr>
            <td>d1</td>
            <td>d2</td>
            <td>d3</td>
        </tr>
        <tr>
            <td>d1</td>
            <td>d2</td>
            <td>d3</td>
        </tr>
    </table>

References