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 Bars

Share

Horizontal Bars

London
Paris
Tokyo
London
Paris
Tokyo
London
Paris
Tokyo
London
Paris
Tokyo

Horizontal bars are common web design elements:

London
Paris
Tokyo

The w3-bar class creates a horizontal bar.

The w3-bar-item class defines the items inside the bar.

Example

<div class="w3-bar w3-green">
  <div class="w3-bar-item">London</div>
  <div class="w3-bar-item">Paris</div>
  <div class="w3-bar-item">Tokyo</div>
</div>

Try It Yourself »


Vertical Bars

Vertical bars (sidebars) are also common in web design:

London
Paris
Tokyo

The w3-bar-block class displays bar items vertically.

Example

<div class="w3-bar-block w3-green" style="width:100px">
  <div class="w3-bar-item">London</div>
  <div class="w3-bar-item">Paris</div>
  <div class="w3-bar-item">Tokyo</div>
</div>

Try It Yourself »



Bar Colors

You can use any color to style a bar:

London
Paris
Tokyo
London
Paris
Tokyo
London
Paris
Tokyo
London
Paris
Tokyo

Example

<div class="w3-bar w3-black">
  <div class="w3-bar-item">London</div>
  <div class="w3-bar-item">Paris</div>
  <div class="w3-bar-item">Tokyo</div>
</div>

Try It Yourself »


Hover Colors

You can use any hover color to style a bar:

Mouse over the bar items to see the effect:

London
Paris
Tokyo

London
Paris
Tokyo

Example

<div class="w3-bar w3-black">
  <div class="w3-bar-item w3-hover-red">London</div>
  <div class="w3-bar-item w3-hover-green">Paris</div>
  <div class="w3-bar-item w3-hover-blue">Tokyo</div>
</div>

Try It Yourself »


Bar Links

Providing navigation is a typical use for bars:


Example

<div class="w3-bar w3-black">
  <a href="#" class="w3-bar-item w3-hover-green">London</a>
  <a href="#" class="w3-bar-item w3-hover-green">Paris</a>
  <a href="#" class="w3-bar-item w3-hover-green">Tokyo</a>
</div>

Try It Yourself »


Bar Buttons

Add w3-button to links to make the entire bar item clickable.

Mouse over the bar items to see the effect:

London
Paris
Tokyo

London
Paris
Tokyo

Example

<div class="w3-bar w3-black">
  <a href="#" class="w3-bar-item w3-button">London</a>
  <a href="#" class="w3-bar-item w3-button">Paris</a>
  <a href="#" class="w3-bar-item w3-button">Tokyo</a>
</div>

Try It Yourself »


Responsive Bar

Use the w3-mobile class to make bar items stack vertically on small screens.

Resize the window to see the effect:

London
Paris
Tokyo

Example

<div class="w3-bar w3-black">
  <a href="#" class="w3-bar-item w3-button w3-mobile">London</a>
  <a href="#" class="w3-bar-item w3-button w3-mobile">Paris</a>
  <a href="#" class="w3-bar-item w3-button w3-mobile">Tokyo</a>
</div>

Try It Yourself »


Right-Aligned Bar Items

Use the w3-right class to move a bar item to the right:

London
Paris
Tokyo

Example

<div class="w3-bar w3-black">
  <a href="#" class="w3-bar-item w3-button">London</a>
  <a href="#" class="w3-bar-item w3-button">Paris</a>
  <a href="#" class="w3-bar-item w3-button w3-right">Tokyo</a>
</div>

Try It Yourself »


What You Have Learned

In this chapter you have learned how to:

  • Create horizontal bars with w3-bar
  • Create bar items with w3-bar-item
  • Create vertical bars with w3-bar-block
  • Create clickable bar items with w3-button
  • Change bar colors and hover colors
  • Create responsive bars with w3-mobile
  • Right-align bar items with w3-right

×

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.