Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade Teachers Spaces Get Certified Upgrade Teachers Spaces
   ❮     
     ❯   

W3.CSSTables


First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67
BoNilsson50
MikeRoss35

W3.CSS Table Classes

W3.CSS provides the following classes for tables:

ClassDefines
w3-tableContainer for an HTML table
w3-stripedStriped table
w3-borderBordered table
w3-borderedBordered lines
w3-centeredCentered table content
w3-hoverableHoverable table
ws-table-allAll properties set

Basic Table

Thew3-table class is used to display a basic table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
<tr>
  <th>First Name</th>
  <th>Last Name</th>
  <th>Points</th>
</tr>
<tr>
  <td>Jill</td>
  <td>Smith</td>
  <td>50</td>
</tr>
</table>
Try It Yourself »


Striped Table

Thew3-striped class is used to add zebra-stripes to a table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Bordered Table

Thew3-bordered class adds a bottom border to each table row:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Striped Bordered Table

Combine thew3-striped class and thew3-bordered class to create a striped bordered table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Border Around a Table

Thew3-border class is used to display a border around a table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Tip: Thew3-border class is not only for tables. It can be used on any HTML element!


Displaying it All

Thews-table-all class combines all of the classes above:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Flipping the Stripes

To flip the stripes (start with the light-grey color), add a <thead> element around the table header row. You must also define a color to be used for the table header row:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67
BoNilson35

Example

<thead>
  <tr class="w3-light-grey">
    <th>First Name</th>
    <th>Last Name</th>
    <th>Points</th>
  </tr>
</thead>
Try It Yourself »

Centering all Content

Thew3-centered class centers the content of the table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Centering one Column

Thew3-center class centers the content of a column:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
<tr>
  <th>First Name</th>
  <th>Last Name</th>
  <th class="w3-center">Points</th>
</tr>
Try It Yourself »

Right Align one Column

Thew3-right-align class right aligns the content of a column:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
<tr>
  <th>First Name</th>
  <th>Last Name</th>
  <th class="w3-right-align">Points</th>
</tr>

Try It Yourself »

Hoverable Table

Thew3-hoverable class adds a grey background color on mouse-over:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Hover Colors

If you want a specific hover color, add any of thew3-hover-color classes to each <tr> element:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<tr class="w3-hover-green">
Try It Yourself »

Combining W3.CSS Classes

Many W3.CSS classes can be used on all HTML elements.

For example: border classes, color classes, font classes, card classes, and more.


 Colored Table Header

Use any of thew3-color classes to display a colored row:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<tr class="w3-red">
  <th>First Name</th>
  <th>Last Name</th>
  <th>Points</th>
</tr>
Try It Yourself »

Colored Table

Use any of thew3-color classes to display a colored table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Responsive Table

Thew3-responsive class creates a responsive table. The table will then scroll horizontally on small screens. When viewing on large screens, there is no difference.

Resize the screen to see the effect on the table below:

First NameLast NamePointsPointsPointsPointsPointsPointsPointsPointsPointsPointsPoints
JillSmith50005000500050005000500050005000500050005000
EveJackson94009400940094009400940094009400940094009400
AdamJohnson67006700670067006700670067006700670067006700

Example

<div>
  <table>
   ... table content ...
  </table>
</div>
Try It Yourself »

Table as a Card

Use aw3-card class to display a table as a card:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Tiny Table

Use thew3-tiny class to display a tiny table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Small Table

Use thew3-small class to display a small table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Large Table

Use thew3-large class to display a large table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

XLarge Table

Use thew3-xlarge class to display an xlarge table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

XXLarge Table

Use thew3-xxlarge class to display an xxlarge table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

XXXLarge Table

Use thew3-xxxlarge class to display an xxxlarge table:

First NameLast NamePoints
JillSmith50
EveJackson94
AdamJohnson67

Example

<table>
Try It Yourself »

Jumbo Table

Use thew3-jumbo class to display a jumbo large table:

First NameLast Name
JillSmith
EveJackson
AdamJohnson

Example

<table>
Try It Yourself »


×

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 ourterms of use,cookies andprivacy policy.

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


[8]ページ先頭

©2009-2025 Movatter.jp