InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS properties

  • CSS3 flexbox
  • all
  • animation
  • background-color
  • background-image
  • border
  • border-color
  • border-radius
  • border-style
  • border-width
  • bottom
  • box-shadow
  • box-sizing
  • calc function
  • clip
  • color
  • color value currentColor
  • color values
  • cursor
  • float
  • font
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight
  • generated content
  • left
  • letter-spacing
  • line-height
  • list-style
  • list-style-image
  • list-style-position
  • list-style-type
  • margin
  • max-height
  • max-width
  • min-height
  • min-width
  • opacity
  • outline
  • outline-color
  • outline-style
  • outline-width
  • overflow
  • padding
  • pointer-events
  • position
  • resize
  • right
  • text-align
  • text-decoration
  • text-indent
  • text-overflow
  • text-shadow
  • text-transform
  • top
  • transform
  • transition
  • transition-delay
  • transition-duration
  • transition-property
  • transition-timing-function
  • visibility
  • white-space
  • word-break
  • word-spacing
  • word-wrap/overflow-wrap
  • z-index
 
  • Home
  • > Tutorials
  • > CSS
  • > CSS properties

CSS box-shadow

on Aug 27, 2016

CSS (CSS3) box-shadow property attaches one or more drop-shadows to the box.

CSS property box-shadow

CSS version: CSS 3
Value: [shadow-x] [shadow-y] [blur-radius] [optional_spread_distance] [color];
inset [shadow-x] [shadow-y] [blur-radius] [optional_spread_distance] [color];
Initial: none
Applies to: all elements

Few points to note:

  1. blur radius spread distance and color are optional.
  2. If the color is absent, the used color is taken from the ‘color’ property
  3. Positive value of shadow-x draws a shadow that is offset to the right of the box. Similarly a negative value to the left.
  4. A positive value of shadow-y offsets the shadow down, a negative one up.
  5. Negative values of blur-radius 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.
  6. Spread distance: Positive values cause the shadow to expand in all directions by the specified radius. Negative values cause the shadow to contract.
  7. If present, the ‘inset’ keyword changes the drop shadow from an outer box-shadow to inner box-shadow.

Example – box-shadow

In the following code, CSS property box-shadow can be changed to the following values
  • 10px 10px gray
  • 10px 10px 10px gray
  • 10px 10px 10px 10px gray
  • 10px 10px
<style type="text/css">
div {
  width: 200px; height: 100px;
  background-color: lightblue;
  box-shadow: 10px 10px gray;
}
</style>
<div>some text</div>
box-shadow refresh done
try it online

Example – inner box-shadow

In the following code, CSS property box-shadow can be changed to the following values
  • inset 10px 10px gray
  • inset 10px 10px 10px gray
  • inset 10px 10px 10px 10px gray
  • inset 10px 10px
<style type="text/css">
div {
  width: 200px; height: 100px;
  background-color: lightblue;
  box-shadow: inset 10px 10px gray;
}
</style>
<div>some text</div>
box-shadow refresh done
try it online

Specification and Browser compatibility

SpecificationStatusCategories
CSS3 Box-shadowW3C Candidate RecommendationCSS3
Desktop
ChromeFirefoxIEEdgeSafariOpera
Yes 10+ Yes 4+ Yes 9+ Yes 12+ Yes 5.1+ Yes 10.5+
Mobile
Android ChromeAndroid FirefoxiOS SafariIE MobileOpera Mobile
Yes 47+ Yes 44+ Yes 5.0-5.1+ Yes 10+ Yes 11+
source: caniuse.com

Suggested posts:

  1. Chrome – disable notifications from a site accepted earlier
  2. WordPress – write custom php log to separate file
  3. CSS selector specificity
  4. HTML5 canvas basic example
  5. CSS attribute presence and value selectors
  6. CSS color values
  7. Jquery – change table cells color based on value
  8. CSS general sibling selector
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CSS, CSS properties, Tutorials, Web Development
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress