Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

W3.CSS Visibility

Share

Show and Hide

W3.CSS makes it easy to show and hide content.

Hide an element, reveal extra details with a button, or choose what appears at different screen sizes.

Hide an Element

Use w3-hide to hide an element.

The class sets display:none, so the hidden element takes up no space in the layout.

Panel 2 is hidden below, so Panel 3 follows Panel 1.

Panel 1

Panel 2

Panel 3

Example

<div class="w3-panel w3-light-grey">
  <p>Panel 1</p>
</div>

<div class="w3-panel w3-pale-blue w3-hide">
  <p>Panel 2</p>
</div>

<div class="w3-panel w3-light-grey">
  <p>Panel 3</p>
</div>
Try it Yourself »

Try removing w3-hide from Panel 2 and run the example again.


Show an Element

Use w3-show to display an element as a block.

A block starts on a new line and normally fills the available width of its parent.

In this example, w3-show makes the second panel visible even though it also has w3-hide.

This panel is hidden.

This panel is visible.

Example

<div class="w3-panel w3-pale-blue w3-hide">
  <p>This panel is hidden.</p>
</div>

<div class="w3-panel w3-pale-blue w3-hide w3-show">
  <p>This panel is visible.</p>
</div>
Try it Yourself »

w3-show-block

The w3-show-block class is another name for w3-show.

Both classes set display:block and produce the same result.


Show an Inline Block

Use w3-show-inline-block when the element should appear within a line of text.

An inline block normally uses only the width its content needs and can sit beside other content.

The label below is revealed beside the word Status.

Status: Saved

Example

<p>Status:
<span class="w3-tag w3-teal w3-hide w3-show-inline-block">Saved</span>
</p>
Try it Yourself »

Try changing w3-show-inline-block to w3-show to see the label become a block.



Toggle Visibility

Use a button and a little JavaScript to show or hide extra content.

Click the button to reveal the details panel, then click it again to hide the panel.

More Details

This panel is now visible.

This paragraph moves down when the panel appears.

Example

<button class="w3-button w3-teal" onclick="toggleVisibilityDemo(this)">Show or hide details</button>

<div id="visibilityDemo" class="w3-panel w3-pale-blue w3-hide">
  <h3>More Details</h3>
  <p>This panel is now visible.</p>
</div>

<p>This paragraph moves down when the panel appears.</p>

<script>
function toggleVisibilityDemo(button) {
  const panel = document.getElementById("visibilityDemo");
  const isVisible = panel.classList.toggle("w3-show");
  button.setAttribute("aria-expanded", isVisible);
}
</script>
Try it Yourself »

The panel starts with w3-hide.

The classList.toggle() method adds w3-show if it is missing and removes it if it is present.

The button's aria-expanded value is updated so assistive technology can announce whether the panel is expanded.


Responsive Visibility

Use the responsive hide classes to hide content at different screen widths.

These classes respond to viewport changes automatically, without JavaScript.

ClassHidden When the Viewport Width Is
w3-hide-small600px or less
w3-hide-medium601px to 992px
w3-hide-large993px or more

The breakpoints use the browser viewport width.

In Tryit, this is the width of the result area.

Resize the window or result area to see which panel disappears.

Hidden on small screens: 600px or less.

Hidden on medium screens: 601px to 992px.

Hidden on large screens: 993px or more.

Example

<div class="w3-panel w3-pale-blue w3-hide-small">
  <p>Hidden on small screens: 600px or less.</p>
</div>
<div class="w3-panel w3-pale-green w3-hide-medium">
  <p>Hidden on medium screens: 601px to 992px.</p>
</div>
<div class="w3-panel w3-pale-yellow w3-hide-large">
  <p>Hidden on large screens: 993px or more.</p>
</div>
Try it Yourself »

Show Content in One Screen Range

Combine two responsive hide classes to show content only in the remaining screen-width range.

For example, w3-hide-medium w3-hide-large hides an element on medium and large screens, so it appears only on small screens.

Only one of these panels is visible in each range.

Shown only on small screens.

Shown only on medium screens.

Shown only on large screens.

Example

<div class="w3-panel w3-pale-blue w3-hide-medium w3-hide-large">
  <p>Shown only on small screens.</p>
</div>
<div class="w3-panel w3-pale-green w3-hide-small w3-hide-large">
  <p>Shown only on medium screens.</p>
</div>
<div class="w3-panel w3-pale-yellow w3-hide-small w3-hide-medium">
  <p>Shown only on large screens.</p>
</div>
Try it Yourself »

Visibility Classes

ClassDescription
w3-hideHides an element and removes its layout space.
w3-showDisplays an element as a block.
w3-show-blockSame as w3-show.
w3-show-inline-blockDisplays an element as an inline block.
w3-hide-smallHides an element on screens 600px wide or smaller.
w3-hide-mediumHides an element on screens from 601px to 992px wide.
w3-hide-largeHides an element on screens 993px wide or larger.

Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.