Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS border-right Property

Posted in CSS Tutorial
Updated on Oct 02, 2024
By Mari Selvan
👁️ 8 - Views
⏳ 4 mins
💬 1 Comment
CSS border-right Property

Photo Credit to CodeToFun

🙋 Introduction

The border-right property in CSS is used to set the style, width, and color of the right border of an element.

This property is particularly useful when you want to emphasize the right edge of a box or create a unique design by styling one side of an element differently from the others.

💡 Syntax

The border-right property can be defined using one or more of the following values:

Syntax
Copied
Copy To Clipboard
element {
  border-right: border-width border-style border-color;
}
  • border-width: Specifies the thickness of the border (e.g., 2px, 0.5em).
  • border-style: Specifies the style of the border (e.g., solid, dotted, dashed).
  • border-color: Specifies the color of the border (e.g., #000000, blue).

🎛️ Default Value

The default value of the border-right property is:

Syntax
Copied
Copy To Clipboard
element{
 border-right: medium none currentcolor;
}

This means:

  • border-width: medium (usually 3-4px depending on the browser).
  • border-style: none (no border is displayed).
  • border-color: currentcolor (inherits the value of the color property of the element).

🏠 Property Values

  • border-width: Specifies the thickness of the border. Common values include thin, medium, thick, or specific measurements like px, em, or %.
  • border-style: Defines the appearance of the border. Common styles include:
    • none: No border.
    • solid: A solid line.
    • dotted: A dotted line.
    • dashed: A dashed line.
    • double: Two solid lines.
    • groove: A 3D grooved border.
    • ridge: A 3D ridged border.
    • inset: A 3D inset border.
    • outset: A 3D outset border.
  • border-color: Specifies the color of the border. Can be a named color, hex code, RGB, HSL, or currentcolor.

📄 Example

In this example, we’ll apply a red, solid, 5px wide right border to 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-right Example</title>
  <style>
    .box {
      border-right: 5px solid red;
      width: 200px;
      height: 100px;
    }
  </style>
</head>
<body>
  <h1>Right Border Example</h1>
  <div class="box">This is a box with a right border.</div>
</body>
</html>

🖥️ Browser Compatibility

The border-right property is supported by all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. This ensures that your design will render consistently across different platforms and devices.

🎉 Conclusion

The border-right property is a versatile tool in CSS that allows you to style the right border of an element independently.

Whether you're looking to create a visual separation, highlight content, or add a unique design element, the border-right property gives you the flexibility to achieve your desired look. Experiment with different styles, widths, and colors to see how this property can enhance your web design.

👨‍💻 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