Skip to Content
Web Design in a Nutshell, 3rd Edition
book

Web Design in a Nutshell, 3rd Edition

by Jennifer Robbins
February 2006
Intermediate to advanced
826 pages
63h 42m
English
O'Reilly Media, Inc.
Content preview from Web Design in a Nutshell, 3rd Edition

Obviously, if the value of visibility is visible (the default), the element will be visible. When it is set to hidden, the element is invisible, but it maintains its spot in the document flow; you just can’t see it. This makes it distinctly different from display: none, which removes the element from of the document flow completely and closes up the space it once occupied.

In this example, an inline text element is hidden (Figure 21-13). It is easy to see that the space for its element box is preserved. Notice also that all aspects of the element (including its content, background, and border) are invisible as well.

    span.a {background-color:#CCCCCC; border: 1px solid #000;visibility: visible;}
    span.b {background-color:#CCCCCC; border: 1px solid #000; visibility: hidden;}

<p>Aliquam pulvinar volutpat nibh. Integer convallis nulla sit amet magna. <span
class="a"> Maecenas imperdiet turpis ac augue. Integer malesuada mauris a
odio vulputate blandit.  Etiam accumsan. </span> Proin eros massa, condimentum sit
amet, semper vitae, pulvinar non, augue.  </p>

<p>Aliquam pulvinar volutpat nibh. Integer convallis nulla sit amet magna. <span
class="b"> Maecenas imperdiet turpis ac augue. Integer malesuada mauris a
odio vulputate blandit.  Etiam accumsan. </span> Proin eros massa, condimentum sit
amet, semper vitae, pulvinar non, augue. </p>
Setting visibility to hidden

Figure 21-13. Setting visibility to hidden

The collapse

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Responsive Web Design with HTML5 and CSS3

Beginning Responsive Web Design with HTML5 and CSS3

Jonathan Fielding

Publisher Resources

ISBN: 0596009879Errata Page