Tillitsdone
down Scroll to discover

CSS border-image-outset Enhance Border Design

The CSS border-image-outset property allows you to extend border images beyond an element's border box.

Use it to create visually appealing designs with length, number, and global values.
thumbnail

Description

The border-image-outset property in CSS is a handy tool for controlling how far a border image extends beyond an element’s border box. By adjusting the outset value, you can push the border image outward, adding extra space around the element without affecting its content. This is great for creating unique and visually appealing designs, making your web pages stand out.

Syntax

The border-image-outset property can be specified using lengths or numbers. Here’s how you can use it:

/* <length> value */
border-image-outset: 1rem;
/* <number> value */
border-image-outset: 1.5;
/* top and bottom | left and right */
border-image-outset: 1 1.2;
/* top | left and right | bottom */
border-image-outset: 30px 2 45px;
/* top | right | bottom | left */
border-image-outset: 7px 12px 14px 5px;
/* Global values */
border-image-outset: inherit;
border-image-outset: initial;
border-image-outset: revert;
border-image-outset: revert-layer;
border-image-outset: unset;

You can use one to four values to specify the outset for different sides of the element. Negative values are not allowed.

Values

The border-image-outset property accepts lengths or numbers:

  • Length (<length>): Specifies the size as a dimension (e.g., px, em, rem).
  • Number (<number>): Specifies the size as a multiple of the element’s border-width.
  • Global Values: Like inherit, initial, revert, revert-layer, and unset.

Formal Definition

  • Initial Value: 0
  • Applies to: All elements, except internal table elements when border-collapse is collapse. Also applies to ::first-letter.
  • Inherited: No
  • Computed Value: As specified, but with relative lengths converted into absolute lengths.
  • Animation Type: By computed value type.

Formal Syntax

border-image-outset =
[ [<length [0,]> | <number [0,]> ]{1,4} ]

Examples

Basic Example

<!DOCTYPE html>
<html>
<head>
<style>
.border-outset {
width: 10rem;
height: 10rem;
border: 1rem solid;
border-image: url('border-image.png') 30 round;
border-image-outset: 1rem;
}
</style>
</head>
<body>
<div class="border-outset">This element has an outset border image!</div>
</body>
</html>

Using Multiple Values

<!DOCTYPE html>
<html>
<head>
<style>
.border-outset-multi {
width: 10rem;
height: 10rem;
border: 1rem solid;
border-image: url('border-image.png') 30 round;
border-image-outset: 1rem 2rem 1.5rem 0.5rem;
}
</style>
</head>
<body>
<div class="border-outset-multi">This element has an outset border image with different values for each side!</div>
</body>
</html>

Using Numbers

<!DOCTYPE html>
<html>
<head>
<style>
.border-outset-number {
width: 10rem;
height: 10rem;
border: 1rem solid;
border-image: url('border-image.png') 30 round;
border-image-outset: 1.5;
}
</style>
</head>
<body>
<div class="border-outset-number">This element has an outset border image using a number value!</div>
</body>
</html>

Using Global Values

<!DOCTYPE html>
<html>
<head>
<style>
.border-outset-global {
width: 10rem;
height: 10rem;
border: 1rem solid;
border-image: url('border-image.png') 30 round;
border-image-outset: inherit;
}
</style>
</head>
<body>
<div class="border-outset-global">This element has an outset border image using a global value!</div>
</body>
</html>

Outsetting a Border Image

<!DOCTYPE html>
<html>
<head>
<style>
.outset-border {
width: 10rem;
background: #cef;
border: 1.4rem solid;
border-image: radial-gradient(#ff2, #55f) 40 round;
border-image-outset: 1.5; /* 1.5 × 1.4rem = 2.1rem */
margin: 2.1rem;
}
</style>
</head>
<body>
<div class="outset-border">This element has an outset border image!</div>
</body>
</html>

Element Styling

  • The .outset-border class is applied to a <div> element.
  • The width property sets the element’s width to 10rem.
  • The background property sets a light blue background color.
  • The border property sets a solid border with a width of 1.4rem.

Border Image

  • The border-image property applies a radial gradient as the border image.
  • The 40 value specifies the width of the border image.
  • The round value repeats the border image to fit the element’s size.

Border Image Outset

  • The border-image-outset property is set to 1.5. This value multiplies the border width (1.4rem) to determine the outset distance. In this case, 1.5 × 1.4rem = 2.1rem.
  • The margin property is set to 2.1rem to ensure that the outset border image does not overlap with other elements.

Result

The element will have a border image that extends 2.1rem beyond its border box, creating a visually appealing effect. The border image will be a radial gradient that transitions from a bright color to a darker blue, adding a dynamic and eye-catching look to the element.

Tips

  • Experiment with Values: Try different values for the border-image-outset property to see how they affect the appearance of your border image. You can use both length values (e.g., px, em, rem) and numbers to achieve the desired effect.
  • Combine with Other Properties: You can combine the border-image-outset property with other CSS properties like border-image-source, border-image-slice, and border-image-repeat to create complex and unique border designs.
  • Browser Compatibility: Ensure that your designs are compatible with the browsers you target. The border-image-outset property is widely supported, but it’s always a good practice to test your designs across different browsers and devices.

Specifications

The border-image-outset property is defined in the CSS Backgrounds and Borders Module Level 3 specification. This module outlines the behavior and usage of various border and background properties, including how to apply and control border images.

Specification Details:

Browser Compatibility

The border-image-outset property is well-established and widely supported across modern browsers. This ensures that you can confidently use this property to create visually appealing designs without worrying about compatibility issues.

Browser Support Table

BrowserVersionRelease Date
Chrome15.0Oct 2011
Firefox15.0Aug 2012
Internet Explorer11.0Oct 2013
Edge12.0Jul 2015
Opera15.0May 2013
Safari6.0Jul 2012

Compatibility Details

  • Chrome: The border-image-outset property has been supported since Chrome 15.0, released in October 2011.
  • Firefox: Firefox has supported this property since version 15.0, released in August 2012.
  • Internet Explorer: Internet Explorer 11.0, released in October 2013, introduced support for border-image-outset.
  • Edge: Microsoft Edge has supported this property since version 12.0, released in July 2015.
  • Opera: Opera has supported border-image-outset since version 15.0, released in May 2013.
  • Safari: Safari has supported this property since version 6.0, released in July 2012.

Checking Browser Compatibility

To ensure that your designs are accessible to a wide range of users, it’s essential to test your web projects across different browsers and devices. You can use tools like BrowserStack or CanIUse to check the compatibility of the border-image-outset property and other CSS features.

Importance of Compatibility

Maintaining browser compatibility is crucial for providing a consistent user experience. By using widely supported properties like border-image-outset, you can create visually appealing designs that work seamlessly across various browsers and devices. This ensures that your web projects are accessible to a broader audience, enhancing user satisfaction and engagement.

FAQs

What is the border-image-outset property in CSS?

The border-image-outset property in CSS determines the distance by which the border image is extended beyond the border box. It essentially pushes the image outward, creating extra space around the element. This property is useful for adding visual interest to your designs by customizing the placement of the border image.

How do I control the amount of space added by border-image-outset?

You can control the space using pixel values, percentage values, or even unitless numbers that scale the image’s outward extension. For example, border-image-outset: 10px; adds 10 pixels of space around the border image. Alternatively, you can use numbers to specify the outset as a multiple of the element’s border width, such as border-image-outset: 1.5;.

Can I use different outset values for each side of the border?

Yes, you can specify different outset values for the top, right, bottom, and left sides individually. For example, border-image-outset: 5px 10px 15px 20px; sets different outset values for each side of the border. This provides flexibility in customizing the appearance of the border image around the element.

How does border-image-outset interact with border-image-slice?

border-image-outset pushes the sliced image outward, which can affect how the image appears in relation to the element’s content and other borders. You may need to adjust both properties to achieve the desired visual effect. For instance, if the sliced image is too large, it might overlap with the outset, requiring fine-tuning of both properties.

Why is my border-image-outset value not making a visible difference?

This could be due to insufficient initial image size, overly large slice settings, or conflicts with other layout properties like margin or padding. Make sure the image is large enough to show the outset effect clearly. Additionally, check for any conflicting CSS properties that might be affecting the display of the border image.

How can I ensure browser compatibility for border-image-outset?

The border-image-outset property is widely supported across modern browsers, including Chrome, Firefox, Safari, Opera, and Edge. However, it’s always a good practice to test your designs across different browsers and devices to ensure compatibility. You can use tools like CanIUse and BrowserStack to check for any potential issues.

Can I animate the border-image-outset property?

Yes, the border-image-outset property can be animated. You can use CSS animations or transitions to change the outset value over time, creating dynamic and engaging visual effects. This can be particularly useful for creating interactive and visually appealing designs.

What are some common use cases for border-image-outset?

border-image-outset is commonly used in web design to create unique and visually appealing border effects. Some common use cases include:

  • Adding extra space around an element to make the border image stand out.
  • Creating custom border designs that extend beyond the element’s border box.
  • Enhancing the visual appeal of buttons, cards, and other UI elements with unique border effects.

How does border-image-outset affect accessibility?

The parts of the border image that are rendered outside the element’s border box with border-image-outset do not trigger overflow scrollbars and don’t capture mouse events. This ensures that the border image does not interfere with the accessibility of the element. However, it’s important to ensure that the overall design remains accessible and user-friendly.

Conclusion

The border-image-outset property is a powerful tool for web developers and designers, allowing them to create unique and visually appealing border effects. With widespread browser support, you can confidently use this property to enhance the design quality of your web projects. By understanding and utilizing the border-image-outset property, you can create stunning designs that captivate your audience and improve the overall aesthetic of your websites.

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.