×

CSS Box-shadow

CSS Box-shadow

This property is referred to include effects as shadow-like around an element’s frame.

Syntax

box-shadow: h-offset v-offset blur spread color |inset|inherit|none;

Property values

Following are the various property values which can be used to provide distinct kind of variations to our elements or text. Let’s have a look:

ValuesDescriptionh-offsetIt sets the horizontal position of the shadow. It includes some positive value that will be used to position the shadow towards the right surface of a box. It includes some negative values that will be used to position the shadow towards the left surface of a box.v-offsetIt sets the vertical position of the shadow. It includes some positive value that will be used to position the shadow down the box. Also, it includes some negative values that will be used to position the shadow over the box.blurAs the name suggests, this value is referred to blur any box-shadow. It is also optional.spreadThis value set-up the size of the shadow. The size of the shadow spread in CSS depends on the value of the spread.colorAs the name suggests, it sets the shadow color. This attribute is optional.insetGenerally, the shadow produces outside of a box, after using the  inset attribute, theshadow may be designed inside a box.initialThis value is generally referred to set-up the box-shadow attribute to its default value.inheritThis value can be acquired from the parent element.noneNone value is a default value, and it does not add any property of shadow.

Example of Box-shadow

Let’s consider the following simple example for box-shadow effect:

<!DOCTYPE html>
<html>
<head>
<title> Box-shadow </title>
<style>
div
{
 border: 1px solid;
 padding: 10px;
}
.hvb
{
 /* box-shadow: h-offset v-offset blur */
 box-shadow: 5px 10px 10px;
}
.spr
{
 /* box-shadow: h-offset v-offset blur spread */
 box-shadow: 5px 10px 10px;
}
.col
{
 /* box-shadow: h-offset v-offset blur spread color */
 box-shadow: 5px 10px 10px 10px lime;
}
.ins
{
 /* box-shadow: h-offset v-offset blur spread color inset */
 box-shadow: 5px 10px 10px 10px lime inset;
}
.init
{
 /* box-shadow: initial */
 box-shadow: initial;
}
.non
{
 /* box-shadow: none */
 box-shadow: none;
}
</style>
</head>
<body>
<div class= "hvb">
<h1> This Box contains blur, v-offset, and h-offset attributes. </h1>
</div>
<br><br>
<div class= "spr">
<h1> This Box contains the spread attributes. </h1>
</div>
<br><br>
<div class= "col">
<h1> This Box contains the color attributes. </h1>
</div>
<br><br>
<div class= "ins">
<h1> This Box contains the inset attributes. </h1>
</div>
<br><br>
<div class= "init">
<h1> This Box contains the initial attributes. </h1>
</div>
<br><br>
<div class= "non">
<h1> This Box contains the default attributes. </h1>
</div>
</body>
</html>

Output:

← Prev Next →


Related Topics

CSS Ellipsis

The CSS ellipsis kind of is the value that mostly is used by the property: text-overflow. Here, we will discuss the following: What is CSS Ellipsis? Syntax for CSS ellipsis How to...

3 minutes read.

CSS 2d Transform

Transform property in CSS is used mainly for enhancing the effects and to animate the elements. Transform is an effect that changes the shape, size and position of an element. It helps...

6 minutes read.

Difference between HTML and CSS

HTML HTML stands for HyperText Markup Language and is used to create web pages and websites and web applications, which means we can create static web pages. Html is a scripting...

3 minutes read.

CSS :root selector

CSS :root selector This CSS pseudo-class matches any document’s root element. It chooses the parent of the highest-level inside the document DOM or tree. An element of <html> is always a...

2 minutes read.

CSS Form

You can create attractive HTML form by using CSS. Style input Fields The Input Field width properties are used to determine the width of the input field. Let us see an example of CSS style...

2 minutes read.

Difference between CSS Grid and CSS Flexbox

The way that information is arranged on a website reveals a lot about you or your company. Organizational abilities are just as important as having the right materials. The design...

3 minutes read.

How To Use CSS

You can use CSS(Cascading Style Sheet) in four ways. These are given below: The given above CSS type, in which various technique will be used. These are different from each other and...

2 minutes read.

CSS Color Keywords

Here, we will discuss the following keywords: transparent currentcolor Inherit Transparent keyword A color can generally be made transparent by using the transparent keyword. Often it is used to for all intents...

4 minutes read.

CSS Content Property

Content Property The content attribute produces dynamic content. It can be applied with any pseudo-element ::after and ::before. These CSS properties are entirely supported inside every browser and applied to include...

5 minutes read.

CSS Page-break-after Attribute

Page-break-after Attribute As its name implies, the page-break-before property is applied to include page break after any element, at the time of printing a document. It adds the page break after...

5 minutes read.

CSS White Space Property

White Space in CSS The white-space CSS property describes how to show the content inside an element. This property is applied to manage a white space within an element. Values of White-space...

2 minutes read.

Css Box Model

Introduction The Box Model property of CSS is used for design and layout of an html page. In CSS, all the elements has a rectangular box around it, you have to...

5 minutes read.

How to change background color in CSS

How to change background color in CSS? The background-color property in CSS would be used to specify the color of an element's background. As the element's background, it uses solid colors. The...

3 minutes read.

Divi in CSS

Divi is popular WordPress themes due to its versatility and user-friendly interface. It includes a built-in page builder for sophisticated design options and an assortment of customization features to help...

9 minutes read.

What is CSS

CSS stands for Cascading Style Sheet. It gives an additional style to the HTML document. A cascading style sheet is a language that is designed to define the document formatting...

3 minutes read.

CSS z-index Property

CSS z-index: CSS z-index permits us to represent any visual hierarchy over a 3D plane that is the z-axis. This index can be applied to describe the positioned element’s stacking...

2 minutes read.

Is CSS a programming language?

 A programming language is a set of grammatical rules and a vocabulary for commanding a machine to accomplish specified tasks. High-level languages like BASIC, C, C++, COBOL, Java, FORTRAN, Ada...

4 minutes read.

CSS Descendant Selector

Descendant Selector The Descendant selector in CSS is used to match the descendant components of a particular component. The term descendant depicts nested in whatever place, inside a DOM tree. This...

2 minutes read.

CSS Links

CSS Link is used to create styled link. There are various ways to implement it. Styling Links Link can be styled with CSS properties like color, font-family, background etc. Example: <!DOCTYPE html>   <html>   <head>   <style>   a {       color: red;   }   </style>   </head>   <body>   <p><b><a href="https://www.tutorialandexample.com"    target="_blank">This is a link</a></b></p>   </body>   </html> Try Now There are four...

2 minutes read.

CSS Reference

The CSS Reference lists all of the basic standard CSS properties, pseudo-classes, pseudo-elements, and data types, for all intents and purposes functional notations, and at-rules alphabetically.  The site also includes...

5 minutes read.