Show Menu
Cheatography

W3.CSS Cheat Sheet (DRAFT) by

A Cheatsheet for the W3.CSS CSS Library

This is a draft cheat sheet. It is a work in progress and is not finished yet.

W3-Colors

Class
Use Case
w3-{color}
Background for any HTML element
w3-tex­t-{­color}
Text (foreg­round color) for a HTML element
w3-hov­er-­{color}
Background color on-hover for any element
w3-hov­er-­tex­t-{­color}
Text (foreg­round) color on-hover for an element
By default, W3 uses Material UI colors for its color scheme. This can be changed to use other schemes like Windows colors, Fashion colors, Highway colors etc.

W3-Borders

Class
Use Case
w3-border
Add a border on all sides of an element
w3-bor­der­-{side}
(
top
,
right
,
bottom
,
left
)
Add a border to a specific side of an element
w3-bor­der­-{c­olor}
Give border a specific color
w3-hov­er-­bor­der­-{c­olor}
Border display color on mouse hover
w3-{si­de}bar
(
left
bottom
,
right
,
top
)
Give the border a thick bar on the specified side
w3-rou­nd-­{size}
(
small
,
no-size
,
medium
,
large
,
xlarge
,
xxlarge
)
Round corners of a border
For a border to be more visible, add a contra­sting background color to the element.

W3-Cards

Class
Use Case
w3-car­d-{­shadow size}
(
no-size
,
2
(2px shadow size),
4
(4px shadow size))
Make a card with the specified shadow size
w3-hov­er-­shadow
Add a shadow effect (4px exact) when you hover over a card
To color the background of a card, use the
w3-{color}
class.

W3-Round

Class
Use Case
w3-round
Adds a
border­-radius
of 4 around an element.
w3-rou­nd-­{size}
(
small
,
medium
,
large
,
xlarge
,
xxlarge
)
Adds
border­-radius
of 2, 4, 8, 16 and 32 respec­tively around an element.
w3-circle
Displays any content inside a circle.
This property simply adds rounded corners to any HTML element. You can use the
w3-circle
class along with
w3-padding
to provide some padding around the element from the circle borders.

W3-Margin

Class
Use Case
w3-margin
Adds a 16px margin to all sides of an element.
w3-mar­gin­-{side}
(
top
,
right
,
bottom
,
left
)
Adds a 16px margin to the specified side of an element.
w3-section
Adds a 16px margin to the top and bottom of an element.
The
w3-section
class exists because by default HTML elements do not have a top and bottom margin around them.

W3 Buttons

Class
Use Case
w3-btn
Creates a rectan­gular, black by default, button with shadow on hover.
w3-button
Creates a rectan­gular button with a grey hover effect.
w3-bar
A horizontal bar that can be used to group buttons together e.g in horizontal menus. Use it as a container for buttons. You can center the buttons using the
w3-center
class.
w3-block
A block defines a full width (100% container width) button.
w3-circle
Can be used to create a circular button.
w3-ripple
Can be used to create a ripple (blink) effect when a button is clicked.
w3-{color}
Used to color the background of the button.
w3-hov­er-­{color}
Used to change the background color on hover.
w3-rou­nd-­{size}
(
normal (w3-round)
,
large
,
xlarge
,
xxlarge
)
Used to add round borders to a button.
w3-{size}
(
tiny
,
small
,
medium
,
large
,
xlarge
,
xxlarge
,
xxxlarge
,
jumbo
)
Used to define size of text in the button.
w3-border
Used to add borders to a button.
w3-bor­der­-{c­olor}
Used to define the color of the border around a button. Can be used with
w3-rou­nd-­{size}
to add rounding to the border.
w3-wide
Can be used to add wide-text effect to text in the button.
w3-pad­din­g-{­size}
(
small
,
large
)
Can be used to add padding around the text in the button.
w3-{si­de}­-align
(
left
,
right
)
Can be used to align the text in the button.
w3-dis­abled
Can be used to make a disabled button. The mouse changes to a no entry sign, and clicking does nothing.
w3-{side}
(
left
,
right
)
Used to float the button to the left or right of the bar.
The
w3-button
inherits its default color from the parent element in w3CSS V4, and is light-gray by default in V3. To add italics or bolding to a text, you can wrap the text around the approp­riate tag e.g
<button class=­"­w3-­but­ton­"><i>­Ita­lic­</i></b­utt­on>
. You can use
style=­width: 80%
to change the width of the button in the parent container.

W3 Quotes

Class
Use Case
 

W3-Con­tainers

Class
Use Case
w3-con­tainer
Add a container class to an element
Containers (e.g
<di­v>
,
<ar­tic­le>
,
<se­cti­on>
,
<he­ade­r>
)provide equality i.e common margins, padding, alignm­ents, font colors etc to all HTML container elements.
The w3-con­tainer class specif­ically adds a 16px left and right padding to any HTML element, but no top and bottom padding. Use it with contai­ners. So paragraphs and headings provide margins that help with this.

W3-Panels

Class
Use Case
w3-panel
Add a panel to an element
w3-{pale background color}
Use a panel as a note area
w3-leftbar
,
w3-rig­htbar
Use a panel for quotes
w3-car­d-{­shadow size}
(no-sh­adow,
2
(2px shadow),
4
(4px shadow))
Use a panel as a card (like a flash card)
w3-rou­nd-­{size}
(
small
,
medium
,
large
,
xlarge
,
xxlarge
)
Round corners of a panel
w3-{size}
(
tiny
,
small
,
medium
,
large
,
xlarge
,
xxlarge
,
xxxlarge
,
jumbo
)
Set size of the panel
A panel is like a container, but it adds a 16px top and bottom margin to the initial 16px left and right provided by a container. To use panels for notes, add a pale background e.g
w3-pal­e-green
.
To use a panel for quotes, give it a left bar or a right bar a size, and serif font. Panels can also be used as cards by adding it to the
W3-Card(s)
classes. See that section for more details.

W3-Fonts

Class
Use Case
w3-{fo­nt-­family}
(
serif
,
sans-serif
,
monospace
,
cursive
)
Make a text font same as the specified family font

W3-Text

Class
Use Case
w3-{si­de}­-align
(
left
,
right
)
Align text to the left or right
w3-center
Center align elements (including text)
w3-wide
Specify wider text
w3-opacity
Give opacity to text. Intensity depends on the color used

W3-Padding

Class
Use Case
w3-pad­din­g-{­number}
(
16
,
24
,
32
,
48
,
64
)
Adds a top and bottom padding to any HTML element.
w3-padding
Adds an 8px top and bottom and 16px left and right padding.
w3-pad­din­g-small
Adds a 4px top and bottom and 8px left and right padding.
w3-pad­din­g-large
Adds a 12px top and bottom and 24px left and right padding.
The number defines the intensity of the padding.

W3 Display

Class
Use Case
w3-dis­pla­y-c­ont­ainer
Container for
w3-dis­play-classes
w3-dis­pla­y-t­opleft
Display elements in top left of display container.
w3-dis­pla­y-t­opright
Display elements in top right of display container.
w3-dis­pla­y-b­ott­omleft
Display elements in bottom left of display container.
w3-dis­pla­y-b­ott­omright
Display elements in bottom right of display container.
w3-dis­pla­y-left
Display elements in the left of display container.
w3-dis­pla­y-right
Display elements in the right of display container.
w3-dis­pla­y-m­iddle
Display elements in the middle of display container.
w3-dis­pla­y-t­opm­iddle
Display elements in top middle of display container.
w3-dis­pla­y-b­ott­omm­iddle
Display elements in bottom middle of display container.
w3-dis­pla­y-p­osition
Display elements in the specified position in the display container.
w3-dis­pla­y-hover
Display contents on hover inside the display container.
w3-left
Float an element to the left (
float: left;
)
w3-right
Float an element to the left (
float: right;
)
w3-show
Shows an element (
display: block;
)
w3-hide
Hide an element (
display: none;
)
w3-mobile
Adds mobile­-first respon­siv­eness to any element.
Display classes allow you to display HTML elements in specific positions inside other HTML elements. They however must be placed in the
w3-dis­pla­y-c­ont­ainer
container. The
w3-mobile
class displays elements as block elements on mobile devices (By adding
displa­y:block
and
width:­100%;
to an element on screen sizes less than 600px wide).

W3 Notes

Class
Use Case
w3-panel
The perfect class to display notes and inform­ation. The panel by default has no border.
w3-{si­de}-bar
(
left
,
right
,
w3-bot­tombar
,
w3-topbar
)
Used to add side bar to the note (panel), The bar becomes a border for the panel.
w3-bor­der­-{c­olor}
You can use this to color the border (bar) from above.
w3-pal­e-{­color}
Use a pale background color to make the note more catchy.
Use
w3-border
to add a border around the note (panel) converse to using
w3-bar
.