CSS border-bottom
The border-bottom
property in CSS is a shorthand property for setting the width, style, and color of an element’s bottom border. This property allows you to control all three aspects of the bottom border in a single declaration.
Syntax of border-bottom
</>
Copy
border-bottom: border-width border-style border-color | initial | inherit;
Values
Value | Description |
---|---|
border-width | Specifies the width of the bottom border. Accepts values like thin , medium , thick , or any valid CSS length unit (e.g., 2px , 0.1em ). |
border-style | Defines the style of the bottom border. Accepts values like none , solid , dashed , dotted , etc. |
border-color | Specifies the color of the bottom border. Accepts any valid CSS color value (e.g., red , #ff0000 , rgba(255,0,0,0.5) ). |
initial | Sets the property to its default value (medium none currentColor ). |
inherit | Inherits the value from its parent element. |
Default Value
medium none currentColor
Examples for border-bottom
Using the CSS border-bottom Property
The following examples demonstrate how to use the border-bottom
property to style the bottom border of an element.
</>
Copy
/* Set the bottom border with width, style, and color */
.element {
border-bottom: 3px solid red;
}
/* Set only the style and color */
.element {
border-bottom: dashed blue;
}
/* Set the bottom border width only */
.element {
border-bottom: 5px;
}
/* Use the initial value */
.element {
border-bottom: initial;
}
/* Inherit the bottom border properties from the parent */
.element {
border-bottom: inherit;
}
Example for Solid Bottom Border
Below is an example demonstrating how to use border-bottom: 4px solid #4CAF50;
to apply a solid green border to the bottom of an element:
index.html
</>
Copy
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.box {
width: 200px;
padding: 20px;
border-bottom: 4px solid #4CAF50;
}
</style>
</head>
<body>
<h2 class="box">Lorem Ipsum</h2>
</body>
</html>

Example for Red Dashed Bottom Border
border-bottom: 10px dashed red;
</>
Copy
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.box {
width: 200px;
padding: 20px;
border-bottom: 10px dashed red;
}
</style>
</head>
<body>
<h2 class="box">Lorem Ipsum</h2>
</body>
</html>

Example for Blue Dotted Bottom Border
border-bottom: 4px dotted rgba(0, 0, 255, 1.0);
</>
Copy
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.box {
width: 200px;
padding: 20px;
border-bottom: 4px dotted rgba(0, 0, 255, 1.0);
}
</style>
</head>
<body>
<h2 class="box">Lorem Ipsum</h2>
</body>
</html>

Browser Support
The border-bottom
property is supported in all major browsers. Below is a compatibility table:
Browser | Version |
---|---|
Chrome | 1.0 |
Edge | 4.0 |
Firefox | 1.0 |
Safari | 1.0 |
Opera | 3.5 |