×

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 Button Style

CSS button style: Using CSS properties, we can easily modify the default BUTTON and enhance its appearances using simple graphic commands. TYPES OF BUTTON STYLE: - Program to change button using CSS ...

35 minutes read.

CSS Position

CSS Position: The position property in CSS is applied to set the position of the elements. It can be used to position the backside of an element. It is also...

3 minutes read.

CSS Dropdowns

Dropdowns are one of the maximum crucial parts of an interactive internet site. CSS is a kind used to design the drop-down menus. A drop-down essentially is a group of...

5 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.

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.

Grid Vs Flexbox in CSS

Grid: - CSS Grid Layout is a 2D grid-based matrix-based layout method with columns and rows that simplifies web pages created by eliminating the need for floats and placement. A grid layout, like...

4 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 Hover

CSS Hover: CSS :hover is used to select the various elements whenever we point the mouse on these elements. We can also use this selector on all the HTML elements,...

3 minutes read.

CSS Introduction

CSS stands for Cascading Style Sheet. It is a design language which is used to design the web pages. It was developed by Håkon Wium Lie on October 10, 1994. It provides...

1 minute read.

Cascading Style Sheet

CSS refers to the Cascading Style Sheet. CSS is a form of a programming language. In other words, CSS is a language of the style sheet that is utilised for...

7 minutes read.

CSS Navigation bar

CSS Navigation bar: A navigation system or navigation bar comes upon GUI that can help many visitors to access the information. A Navigation bar is a UI component on the...

11 minutes read.

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.

How to Set Space between the Flexbox

For managing layout on the Web, CSS Flexbox and CSS Grid are two excellent tools. Flexbox handles one-dimensional layouts quite well, whereas CSS Grid manages two-dimensional layouts with columns and...

4 minutes read.

CSS Pseudo-elements

Pseudo-elements The pseudo-classes in CSS can be represented as any keyword which is connected to the selector that represents any selected element’s unique state. On the other hand, pseudo-elements can be...

6 minutes read.

CSS User Interface

Introduction User Interface can be defined as series of visual elements like screens, buttons, forms that help the user interact with the software application or hardware device. CSS User Interface allows the...

6 minutes read.

How to change font size in CSS

How to change font size in CSS? Font Size: - Users may attract attention to content on a website page in various ways. One element in a sentence can be highlighted. You...

5 minutes read.

Hover condition for a:before and a:after in CSS

In CSS, :after and :before are used to add content after and before the element. The CSS pseudo-class is used to add some styling effect to the webpage. We can change...

4 minutes read.

CSS Width

CSS Width The width property in CSS sets the content width of area of the element. These properties do not provide margin and border features. It is used to set the...

1 minute read.

CSS Gradient

CSS Gradient: The CSS gradient property is applied to show the smooth transition inside two specified colors or more than two specified colors. Need of CSS Gradient The following are a few...

4 minutes read.

How to resize an image in CSS

How to resize an image in CSS? The resize image attribute is used in responsive web design to resize images to fit within the div container automatically. The resize image attribute...

3 minutes read.