Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS border-block-style Property

Posted in CSS Tutorial
Updated on Aug 16, 2024
By Mari Selvan
👁️ 4 - Views
⏳ 4 mins
💬 1 Comment
CSS border-block-style Property

Photo Credit to CodeToFun

🙋 Introduction

The border-block-style property in CSS is a shorthand property that allows you to define the style of the block-start and block-end borders of an element. In a writing mode, "block" refers to the top and bottom borders in a horizontal writing mode (such as English) or the right and left borders in a vertical writing mode (such as Japanese).

This property is useful for setting the style of borders along the block axis, providing more control and flexibility in your design.

💡 Syntax

The border-block-style property can be used with one or two values. If one value is specified, it applies to both the block-start and block-end borders. If two values are specified, the first applies to the block-start border, and the second applies to the block-end border.

Syntax
Copied
Copy To Clipboard
element {
  border-block-style: style;
}
  • style: Specifies the line style of the border. This can be any valid border style value like solid, dashed, dotted, double, groove, ridge, inset, outset, none, or hidden.

🎛️ Default Value

The default value for border-block-style is none, which means that no border is drawn unless a specific style is defined.

🏠 Property Values

ValueDescription
solidDefines a solid border.
dashedDefines a dashed border.
dottedDefines a dotted border.
doubleDefines a double-line border.
grooveDefines a border with a grooved edge.
ridgeDefines a border with a ridged edge.
insetDefines an inset border that makes the element appear embedded.
outsetDefines an outset border that makes the element appear embossed.
noneNo border is drawn.
hiddenThe border is not visible.

📄 Example

In this example, we'll set different styles for the block-start and block-end borders of a div element.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS border-block-style Example</title>
  <style>
    div {
      border-block-style: solid dashed;
      border-block-width: 4px;
      border-block-color: #0073e6;
    }
  </style>
</head>
<body>
  <h1>Block Border Styles</h1>
  <div>
    This `div` element has a solid block-start border and a dashed block-end border.
  </div>
</body>
</html>

🖥️ Browser Compatibility

The border-block-style property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.

🎉 Conclusion

The border-block-style property provides a convenient way to control the appearance of borders along the block axis in your web design. Whether you want to apply the same border style to both the block-start and block-end sides or specify different styles for each, this property offers flexibility in achieving the desired visual effect. Experiment with different styles to enhance the borders of your elements and improve the overall design of your website.

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy