The Wayback Machine - https://web.archive.org/web/20241122161132/https://www.geeksforgeeks.org/css-border-bottom-property/
Open In App

CSS border-bottom Property

Last Updated : 23 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The border-bottom property in CSS is used to set all bottom border properties in one line. It is used to set the width, style, and color of the bottom border. The default value is initial. 

Syntax

border-bottom: border-width border-style border-color|initial|inherit; 

Property Values

border-bottom is a shorthand to set the below property values:

Values

Descriptions

border-width

It is used to set the width of the border.

border-style

It is used to set the style of border. Its default value is ‘none’.

border-color

It is used to set the color of border.

initial

This property is used to set border-bottom to its default value.

inherit

This property is inherited from its parent.

Example: 

html
<!DOCTYPE html>
<html>

<head>
    <title>border-bottom property</title>

    <!-- border-bottom CSS property -->
    <style>
        h1 {
            border-bottom: 5px solid green;
        }

        h2 {
            border-bottom: 4px dotted black;
        }
    </style>
</head>

<body style="text-align:center">
    <h1>GeeksforGeeks</h1>
    <h2>border-bottom property</h2>
</body>

</html>

Output: 

Supported Browsers

The browser supported by border-bottom property are listed below: 

  • Google Chrome 1.0
  • Edge 12.0
  • Firefox 1.0
  • Opera 3.5
  • Safari 1.0

CSS border-bottom Property – FAQs

What is the border-bottom property in CSS?

The border-bottom property in CSS is a shorthand property that sets the width, style, and color of an element’s bottom border. It allows you to define the appearance of the bottom edge in a single declaration.

How do I create a dashed bottom border in CSS?

You can create a dashed bottom border using: border-bottom: 2px dashed #000;. This creates a 2px wide, dashed black border at the bottom of the element.

Can I control the border-bottom separately from other borders?

Yes, the border-bottom property is independent of other sides. You can apply a unique style, width, and color to the bottom border without affecting the top, left, or right borders.

What happens if I only define border-bottom without specifying width, style, or color?

If you don’t specify the width, style, or color, the browser applies default values: medium width, none style (which makes it invisible), and current color. It’s essential to at least specify a style (e.g., solid) to make the border visible.

Why is my border-bottom not appearing?

Common issues include missing the required border style (like solid), having a transparent color, or conflicts with other styles like background colors. Ensure the border style and color are defined correctly.


Previous Article
Next Article

Similar Reads

CSS border-bottom-color Property
The CSS border-bottom-color property is used to set the color of the bottom border of an element. It is mandatory to declare the border-style or border-bottom-style property before using the border-bottom-color property always as there must exist a border first before we change its color. The current value of the element is the default color of thi
2 min read
CSS border-bottom-left-radius Property
The border-bottom-left-radius property is used to define the radius of the bottom left corner of the border i.e. it makes the bottom-left of the border rounded. Syntax:  border-bottom-left-radius: length|% [length|%]|initial|inherit;Default Value: its default value is 0.  Property Value:  Length: This property is used to specify the radius of the b
3 min read
CSS border-bottom-right-radius Property
The border-bottom-right-radius property in CSS is used to define the radius of the right bottom corner of the border of a given element. It is used to round the corner on the right side of the bottom border.  Syntax: border-bottom-right-radius:length|[value%]|initial|inherit;Property Value: The border-bottom-right-radius property values are listed
3 min read
CSS border-bottom-style Property
The border-bottom-style property in CSS is used to set the style of the bottom border of an element.  Syntax:  border-bottom-style: none|hidden|dotted|dashed| solid|double|groove|ridge|inset| outset|initial|inherit;Property Values:  none: It is the default value and it makes the width of the bottom border zero. Hence, it is not visible.hidden: It i
6 min read
CSS border-bottom-width Property
The border-bottom-width property in CSS is used to set a specific width to the bottom border of an element. The border-bottom-style or border-style property is used for the element before using the border-bottom-width property. Syntax: border-bottom-width: length|thin|medium|thick|initial|inherit;Property Values: The border-bottom-width property va
2 min read
How to set the width of the bottom border in CSS ?
In this article we will learn about how to set the width of the bottom border in CSS, We can set the width of the bottom border using the border-bottom-width CSS property. We can give the size in pixels and also can give predefined values such as thick, thin...etc. Approach 1: We will use inline CSS inside the tags.We will use border-color, border-
2 min read
How to define the border bottom color is animatable in CSS ?
In this article, we will learn How to define the border-bottom-color is animatable in CSS. Animating the border-bottom-color of an element helps draw attention to it and make it more visually interesting. Approach: The border-bottom-color is the color of the bottom border, and we want to animate its color. To do that, we will use the animation prop
1 min read
How to set the width of the bottom border animatable using CSS ?
In this article, we will learn to set the width of the border-bottom animate using CSS. Approach: The border-bottom-width is the width of the bottom border, and we want to animate its width. We will use the animation property of the CSS. It takes three values The first is the name of the animation which is a keyframe name that we want to bind with.
1 min read
How to add border-bottom to table row <tr> in CSS ?
A border is an important component of any table in HTML. It is used to define the boundaries of the table and its elements. The border-bottom property is used to add a border to the bottom of an HTML element. In this article, we will discuss how to add a border-bottom to table row <tr>. When applied to a table row, it creates a border that se
3 min read
How to apply bottom border with only Input text field using CSS ?
Adding a bottom border to the input field visually distinguishes it from surrounding elements on the page. Making input fields stand out on a website in a form for example is crucial. Styling these inputs with clear borders, appealing colors, and effects, can easily capture the user’s attention. Table of Content Using the outline and border-bottom
3 min read
How to set the style of the bottom border with JavaScript ?
In this article, we will see how to set the style of the bottom border using JavaScript. To set the border-bottom of an element using JavaScript, we will use the borderBottomStyle property. The style borderBottomStyle property is used to set or return the style of the bottom border of an element. Approach 1: In this approach, we will add the border
2 min read
Which one should we use 'border: none' or 'border: 0 '?
In this article, we will learn the validity of CSS border properties. We can specify the no border property using CSS border: none, border-width : 0, border : 0 properties. Syntax: border: none | 0 Differences: border: noneborder : 0For this property, the browser does not render.For this property, the browser renders border-color and border-width p
1 min read
CSS scroll-margin-bottom Property
The scroll-margin-bottom property is used to set all the scroll margins to the bottom of an element at once. The value specified for the scroll-margin-bottom determines how much of the page that is primarily outside the support should remain visible. Hence, the scroll-margin-bottom values represent outsets that define the scroll snap area that is u
2 min read
CSS bottom Property
The CSS bottom property affects the vertical position of a positioned element. This property does not affect non-positioned elements. It controls an element's vertical distance from the bottom edge of its containing element using units like pixels, percentages, or keywords (auto, initial, inherit). CSS bottom Property UsagePosition and bottom Prope
4 min read
CSS margin-bottom Property
The CSS margin-bottom property is used to specify the amount of margin to be used on the bottom of an element. The margin can be set in terms of length or percentage. Syntax: margin-bottom: <length> | <percentage> | autoProperty values: Length: This value specifies the length of the margin with a fixed value. This value can be positive,
3 min read
CSS padding-bottom Property
An element's padding is the space between its content and its border. The padding-bottom CSS property is used to set the height of the padding area on the bottom of an element. Syntax: padding-bottom: length|percentage;Property values: length: This value is used to specify the size of padding as a fixed value. The default value is 0. It must be non
3 min read
CSS | border-inline-start-style Property
The border-inline-start-style property is an inbuilt property in CSS it is used to define the individual logical inline-end border property values in a single place in the style sheet. This property sets the border-style at the left of the defining element border. Syntax: border-inline-start-style: border-style; Property values: border-style: This
1 min read
CSS | border-block-start-style Property
The border-block-start-style property in CSS is used to define the individual logical block-start border property values in a single place in the style sheet. This property sets the border-style at the top of the defining element border. Syntax: border-block-start-style: border-style; Property values: border-style: This property holds the style of
1 min read
CSS | border-block-start-color Property
The border-block-start-color property in CSS is used to define the individual logical block-start border property values in a single place in the style sheet. This property sets the border-color at the top of the defining element border. Syntax: border-block-start-color: border-color; Property values: border-color: This property holds the color of
1 min read
CSS | border-block-start-width Property
The border-block-start-width property in CSS is used to define the individual logical block-start border property values in a single place in the style sheet. This property sets the border-width at the top of the defining element border. Syntax: border-block-start-width: border-width; Property values: border-width: This property holds the width of
1 min read
CSS | border-block-start Property
The border-block-start property in CSS is used to define the individual logical block-start border property values in a single place in the style sheet. This property place the border at the top of the defining element. Syntax: border-block-start: border-width|border-style|border-color; Property values: border-width: This property value holds the w
2 min read
CSS | border-block-style Property
The border-block-style property in CSS is used to set the individual logical block border-style property values in a single place in the style sheet. It sets the border style top, and bottom of the defining border element. Syntax: border-block-style: style; Property values: style: This property holds the style of the border dashed, border, dotted,
2 min read
CSS | border-block-color Property
The border-block-color property in CSS is used to set the individual logical block border-color property values in a single place in the style sheet. It sets the border color top, and bottom of the defining border element. Syntax: border-block-color: color; Property values: color: This property holds the color of the border. Below examples illustra
1 min read
CSS | border-block-end Property
The border-block-end property in CSS is used to define the individual logical block-end border property values in a single place in the style sheet. This property place the border at the bottom of the defining element. Syntax: border-block-end: border-width|border-style|border-color; Property values: border-width: This property value holds the widt
2 min read
CSS | border-block-end-width Property
The border-block-end-width property in CSS is used to define the individual logical block-end border property values in a single place in the style sheet. This property sets the border-width at the bottom of the defining element border. Syntax: border-block-end-width: border-width; Property values: border-width: This property holds the width of the
1 min read
CSS | border-block-end-color Property
The border-block-end-color property in CSS is used to define the individual logical block-end border property values in a single place in the style sheet. This property sets the border-color at the bottom of the defining element border. Syntax: border-block-end-color: border-color; Property values: border-color: This property holds the color of the
1 min read
CSS | border-start-start-radius Property
The border-start-start-radius property in CSS is used to specify the logical border-radius at the block-start border(top-left). It is adjustable with the element's writing-mode, direction, and text-orientation. Syntax: border-start-start-radius: length | percentage; Property values: length: This property holds the border radius length in a specific
1 min read
CSS | border-end-start-radius Property
The border-end-start-radius property in CSS is used to specify the logical border-radius at the block-start border. It is adjustable with the element's writing-mode, direction, and text-orientation. Syntax: border-end-start-radius: length | percentage; Default Value : Its default value is 0. Property values: length: This property holds the border r
2 min read
CSS | border-end-end-radius Property
The border-end-end-radius property in CSS is used to specify the logical border-radius at the block-end border. It is adjustable with the element's writing-mode, direction, and text-orientation. Syntax: border-end-end-radius: length | percentage; Property values: length: This property hold the border radius length in specific unit. percentage: This
1 min read
CSS | border-inline-style Property
The border-inline-style property is an inbuilt property in CSS which is used to set the individual logical block inline-border-style property values in a single place in the style sheet. It sets the inline border-style top(left), and bottom(right) of the defining border element. Syntax: border-inline-style: style; Property values: style: This prope
1 min read
three90RightbarBannerImg