Tillitsdone
down Scroll to discover

CSS border-bottom-width Customizing Bottom Border Width

Learn about the CSS border-bottom-width property.

Discover how to customize the bottom border width of elements using keywords like thin, medium, and thick, or specific length values.

Enhance your web design with precise border control.
thumbnail

Introduction

The border-bottom-width CSS property lets you set the width of the bottom border of an element. It’s a handy tool for web developers who want to customize the look of their web pages. You can define this property using keywords like thin, medium, and thick, or specify an exact length using units like px, em, or vmax. This gives you the flexibility to style the bottom border to fit your design needs.

Syntax

The border-bottom-width property is easy to use. Here’s how you can define it in CSS:

/* Keyword values */
border-bottom-width: thin;
border-bottom-width: medium;
border-bottom-width: thick;
/* <length> values */
border-bottom-width: 10em;
border-bottom-width: 3vmax;
border-bottom-width: 6px;
/* Global keywords */
border-bottom-width: inherit;
border-bottom-width: initial;
border-bottom-width: revert;
border-bottom-width: revert-layer;
border-bottom-width: unset;

These options let you control the width of the bottom border precisely. Whether you prefer keywords or exact measurements, you can achieve the desired border width.

Values

The border-bottom-width property can take several values, each defining the width of the bottom border differently. Here are the values you can use:

Keyword Values

  • thin: Sets the border width to a thin line.
  • medium: Sets the border width to a medium line.
  • thick: Sets the border width to a thick line.

Note: The exact thickness of thin, medium, and thick isn’t defined by CSS and may vary between browsers. However, it always follows the pattern thin ≤ medium ≤ thick, and the values remain consistent within a single document.

Length Values

You can also specify the width using CSS length units. Examples include:

  • 10em: Sets the border width to 10 times the font size of the element.
  • 3vmax: Sets the border width to 3% of the viewport’s larger dimension (width or height).
  • 6px: Sets the border width to 6 pixels.

Global Keywords

  • inherit: Inherits the border width from the parent element.
  • initial: Sets the border width to its default value.
  • revert: Resets the border width to the browser’s default.
  • revert-layer: Resets the border width to the default value as defined by the user-agent stylesheet or user stylesheet.
  • unset: Resets the border width to its initial value if it is inheritable, or to its inherited value if it is not inheritable.

These values let you precisely control the appearance of the bottom border, making it easier to create visually appealing and functional web designs.

Formal Definition

The border-bottom-width property is formally defined to control the width of the bottom border of any HTML element. Here are the key details about its formal definition:

Initial Valuemedium
Applies ToAll elements. It also applies to the ::first-letter pseudo-element.
InheritedNo
Computed ValueThe absolute length or 0 if border-bottom-style is none or hidden.
Animation TypeA length

Formal Syntax

The formal syntax for the border-bottom-width property is as follows:

border-bottom-width =
<line-width>
<line-width> =
[<length [0,]>] |
thin |
medium |
thick

This syntax specifies that the border-bottom-width can be set using:

  • A non-negative length value.
  • The keywords thin, medium, or thick.

Understanding the formal definition and syntax ensures you use the border-bottom-width property correctly and effectively in your web projects.

Examples

To better understand how the border-bottom-width property works, let’s look at some practical examples. These examples demonstrate different ways to apply the border-bottom-width property to HTML elements.

Comparing Bottom Border Widths

HTML

<div>Element 1</div>
<div>Element 2</div>

CSS

div {
border: 1px solid red;
margin: 1em 0;
}
div:nth-child(1) {
border-bottom-width: thick;
}
div:nth-child(2) {
border-bottom-width: 2em;
}

Result

In this example, the first div uses the thick keyword to set its bottom border width, while the second div uses a length value of 2em. This comparison shows how different values affect the appearance of the bottom border.

More Examples

HTML

<div class="border-bottom-example">border-bottom-width: thin</div>
<div class="border-bottom-example">border-bottom-width: medium</div>
<div class="border-bottom-example">border-bottom-width: thick</div>
<div class="border-bottom-example">border-bottom-width: 5px</div>
<div class="border-bottom-example">border-bottom-width: 1em</div>

CSS

.border-bottom-example {
padding: 20px;
border-bottom-style: solid;
border-bottom-color: tomato;
margin: 1em 0;
}
.border-bottom-example:nth-child(1) {
border-bottom-width: thin;
}
.border-bottom-example:nth-child(2) {
border-bottom-width: medium;
}
.border-bottom-example:nth-child(3) {
border-bottom-width: thick;
}
.border-bottom-example:nth-child(4) {
border-bottom-width: 5px;
}
.border-bottom-example:nth-child(5) {
border-bottom-width: 1em;
}

Result

This example demonstrates the use of different values for the border-bottom-width property. Each div element has a bottom border with a different width, showcasing the flexibility and variety of options available with this property.

Using border-bottom-width

The default border-bottom-width is medium or 1 pixel. To make the border visible, you also need to set the border-bottom-style property. Here’s an example of how to use border-bottom-width effectively:

HTML

<div class="border-bottom-thin">An element with a thin bottom border</div>
<div class="border-bottom-medium">An element with a medium bottom border</div>
<div class="border-bottom-thick">An element with a thick bottom border</div>

CSS

.border-bottom-thin {
padding: 20px;
border-bottom-style: solid;
border-bottom-color: tomato;
border-bottom-width: thin;
}
.border-bottom-medium {
padding: 20px;
border-bottom-style: solid;
border-bottom-color: tomato;
border-bottom-width: medium;
}
.border-bottom-thick {
padding: 20px;
border-bottom-style: solid;
border-bottom-color: tomato;
border-bottom-width: thick;
}

Result

This example shows how to apply different border widths to elements using the thin, medium, and thick keywords. Each div has a bottom border with a different width, illustrating the visual impact of these keywords.

By exploring these examples, you can gain a better understanding of how to use the border-bottom-width property to enhance the visual design of your web pages.

Specifications

The border-bottom-width property is defined in the CSS Backgrounds and Borders Module Level 3 specification. This module specifies the properties related to the background and border styling of HTML elements, including the width of the bottom border.

Here is a reference to the relevant specification:

Specification
CSS Backgrounds and Borders Module Level 3

This specification provides detailed information about the border-bottom-width property, including its syntax, values, and usage. It ensures that the property is implemented consistently across different browsers, allowing web developers to create visually appealing and functional web designs.

Understanding the specifications helps ensure that you use the border-bottom-width property correctly and effectively in your web projects. It provides a solid foundation for implementing consistent and standardized web designs.

To learn more about the border-bottom-width property and its specifications, you can refer to the official documentation linked above. This resource offers in-depth information and guidelines for using the property in your web development projects.

Browser Compatibility

The border-bottom-width property is widely supported across modern web browsers, making it a reliable choice for customizing the appearance of your web pages. Here is an overview of the browser compatibility for this property:

BrowserVersionRelease Date
Google Chrome1.0December 2008
Mozilla Firefox1.0November 2004
Internet Explorer/Edge4.0September 1997
Opera3.5November 1998
Safari1.0June 2003

Additional Notes

  • Google Chrome: The border-bottom-width property has been supported since the first release of Google Chrome in December 2008.
  • Mozilla Firefox: Support for the border-bottom-width property was introduced in Mozilla Firefox 1.0, released in November 2004.
  • Internet Explorer/Edge: Internet Explorer has supported this property since version 4.0, released in September 1997. Microsoft Edge, being a modern browser, also fully supports this property.
  • Opera: The border-bottom-width property has been supported in Opera since version 3.5, released in November 1998.
  • Safari: Safari has supported this property since its first release, version 1.0, in June 2003.

Related Properties

When working with the border-bottom-width property, it’s important to be aware of other related CSS properties that can help you control the appearance of borders more effectively. These properties allow you to customize various aspects of the border, including its style, color, and width, for different sides of an element.

Here are some related properties you might find useful:

Border-Width-Related Properties

  • border-left-width: Sets the width of the left border.
  • border-right-width: Sets the width of the right border.
  • border-top-width: Sets the width of the top border.
  • border-width: A shorthand property that sets the width of all four borders.

Border-Bottom-Related Properties

  • border-bottom-color: Sets the color of the bottom border.
  • border-bottom-style: Sets the style of the bottom border.
  • border-bottom: A shorthand property that sets the width, style, and color of the bottom border.

These properties work together to give you full control over the appearance of borders on your web elements. Understanding and using them effectively can help you create stunning and functional web designs.

By combining these properties, you can achieve a wide range of visual effects and enhance the overall look and feel of your web pages.

icons/css-4.svg CSS Blogs
CSS3 is the latest version of Cascading Style Sheets, offering advanced styling features like animations, transitions, shadows, gradients, and responsive design.
icons/logo-tid.svg

Talk with CEO

Ready to bring your web/app to life or boost your team with expert Thai developers?
Contact us today to discuss your needs, and let’s create tailored solutions to achieve your goals. We’re here to help at every step!
🖐️ Contact us
Let's keep in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.