CSS box-shadow Property

Description

The box-shadow property adds a shadow to an element. It is allowed to use several shadows, indicating their parameters separated by a comma, when applying shadows, the first shadow in the list will be higher, the last lower. If a round radius is set for an element through the border-radius property, then the shadow will also turn out with rounded corners. Adding a shadow increases the width of the element, so a horizontal scrollbar may appear in the browser.

Need some help with the box-shadow property? If yes, then check out our online CSS Box Shadow Generator to see the box-shadow property being used.
Initial value
none
Applies to
All elements
Inherited
No
Media
Visual
Computed value
Any <length> made absolute; any specified color computed; otherwise as specified
Animatable
Yes
CSS Version
CSS3
JavaScript syntax
object.style.boxShadow

Syntax

box-shadow: none | <shadow> [ , <shadow> ]* 

Values

<shadow> = inset? && <length>{2,4} && <color>?
  • 1st <length>Specifies the horizontal offset of the shadow. A positive value draws a shadow that is offset to the right of the box, a negative length to the left.
  • 2nd <length>Specifies the vertical offset of the shadow. A positive value offsets the shadow down, a negative one up.
  • 3rd <length>Specifies the blur radius. Negative values are not allowed. If the blur value is zero, the shadow's edge is sharp. Otherwise, the larger the value, the more the shadow's edge is blurred.
  • 4th <length>Specifies the spread distance. Positive values cause the shadow to expand in all directions by the specified radius. Negative values cause the shadow to contract.
  • <color>Specifies the color of the shadow. If the color is absent, the used color is taken from the 'color' property.
  • insetIf present, the 'inset' keyword changes the drop shadow from an outer box-shadow (one that shadows the box onto the canvas, as if it were lifted above the canvas) to an inner box-shadow (one that shadows the canvas onto the box, as if the box were cut out of the canvas and shifted behindit).

Example

<div class="shadow">Example of the box-shadow css property.</div>
<div class="shadowinset">Example of the box-shadow css property (inset).</div>
.shadow { 
   background: #fc0; 
   box-shadow: 0 0 10px rgb(255,0,0); 
   padding: 10px; 
   margin-bottom: 20px;
} 
.shadowinset { 
   background: #fc0; 
   box-shadow: inset 0 0 10px rgb(255,0,0); 
   padding: 10px; 
} 

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
91210410.55.1
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
≤37184Yes5X

Last updated by CSSPortal on: 20th October 2019


CSS Properties

align-content
align-items
align-self
all
animation
animation-delay
animation-direction
animation-duration
animation-fill-mode
animation-iteration-count
animation-name
animation-play-state
animation-timing-function
backface-visibility
background
background-attachment
background-blend-mode
background-clip
background-color
background-image
background-origin
background-position
background-repeat
background-size
border
border-bottom
border-bottom-color
border-bottom-left-radius
border-bottom-right-radius
border-bottom-style
border-bottom-width
border-collapse
border-color
border-image
border-image-outset
border-image-repeat
border-image-slice
border-image-source
border-image-width
border-left
border-left-color
border-left-style
border-left-width
border-radius
border-right
border-right-color
border-right-style
border-right-width
border-spacing
border-style
border-top
border-top-color
border-top-left-radius
border-top-right-radius
border-top-style
border-top-width
border-width
bottom
box-decoration-break
box-shadow
box-sizing
break-after
break-before
break-inside
caption-side
caret-color
clear
clip-path
color
column-count
column-fill
column-rule
column-rule-color
column-rule-style
column-rule-width
column-span
column-width
columns
content
counter-increment
counter-reset
counter-set
cursor
direction
display
empty-cells
filter
flex
flex-basis
flex-direction
flex-flow
flex-grow
flex-shrink
flex-wrap
float
font
font-family
font-feature-settings
font-kerning
font-language-override
font-size
font-size-adjust
font-stretch
font-style
font-synthesis
font-variant
font-variant-alternates
font-variant-caps
font-variant-east-asian
font-variant-ligatures
font-variant-numeric
font-variant-position
font-weight
grid
grid-area
grid-auto-columns
grid-auto-flow
grid-auto-rows
grid-column
grid-column-end
grid-column-gap
grid-column-start
grid-gap
grid-row
grid-row-end
grid-row-gap
grid-row-start
grid-template
grid-template-areas
grid-template-columns
grid-template-rows
hanging-punctuation
height
hyphens
image-orientation
justify-content
justify-items
justify-self
left
letter-spacing
line-break
line-height
list-style
list-style-image
list-style-position
list-style-type
margin
margin-bottom
margin-left
margin-right
margin-top
max-height
max-width
min-height
min-width
mix-blend-mode
object-fit
object-position
opacity
order
orphans
outline
outline-color
outline-offset
outline-style
outline-width
overflow
overflow-wrap
overflow-x
overflow-y
padding
padding-bottom
padding-left
padding-right
padding-top
perspective
perspective-origin
place-content
place-items
place-self
position
quotes
resize
right
shape-image-threshold
shape-margin
shape-outside
tab-size
table-layout
text-align
text-align-last
text-combine-upright
text-decoration
text-decoration-color
text-decoration-line
text-decoration-style
text-emphasis
text-emphasis-color
text-emphasis-position
text-emphasis-style
text-indent
text-justify
text-orientation
text-overflow
text-shadow
text-transform
text-underline-position
top
transform
transform-origin
transform-style
transition
transition-delay
transition-duration
transition-property
transition-timing-function
unicode-bidi
vertical-align
visibility
white-space
widows
width
word-break
word-spacing
word-wrap
writing-mode
z-index