Search results
Learn how to use the CSS border properties to specify the style, width, and color of an element's border. See examples of different border styles, such as dotted, dashed, solid, double, groove, ridge, inset, outset, none, and hidden.
- Border Width
CSS Border Width. The border-width property specifies the...
- CSS Backgrounds
You learned from our CSS Colors Chapter, that you can use...
- CSS border property
The border property is a shorthand property for:...
- Border Sides
If the border-style property has four values: border-style:...
- Border Width
- Overview
- Constituent properties
- Syntax
- Description
The border shorthand CSS property sets an element's border. It sets the values of border-width, border-style, and border-color.
This property is a shorthand for the following CSS properties:
•border-color
•border-style
•border-width
Values
Sets the thickness of the border. Defaults to medium if absent. See border-width. Sets the style of the border. Defaults to none if absent. See border-style. Sets the color of the border. Defaults to currentcolor if absent. See border-color.
As with all shorthand properties, any omitted sub-values will be set to their initial value. Importantly, border cannot be used to specify a custom value for border-image, but instead sets it to its initial value, i.e., none.
The border shorthand is especially useful when you want all four borders to be the same. To make them different from each other, however, you can use the longhand border-width, border-style, and border-color properties, which accept different values for each side. Alternatively, you can target one border at a time with the physical (e.g., border-top ) and logical (e.g., border-block-start) border properties.
The border property is a shorthand property for: border-width; border-style (required) border-color; If border-color is omitted, the color applied will be the color of the text. Show demo
- medium none color
- CSS1
- no
Aug 31, 2011 · Get started with $200 in free credit! The border property is a shorthand syntax in CSS that accepts multiple values for drawing a line around the element it is applied to. .belement{ border: 3px solid red; width: 200px; aspect-ratio: 1; }
- Animated Border Image. Compatible browsers: Chrome, Edge, Firefox, Opera, Safari. Responsive: no. Dependencies:
- Partial Gradient Border. Partial gradient border surrounding a circle image, which is done with a CSS conic gradient and a radial gradient mask. Compatible browsers: Chrome, Edge, Firefox, Opera, Safari.
- Gradient Border with Rounded Corners. Compatible browsers: Chrome, Edge, Firefox, Opera, Safari. Responsive: no. Dependencies:
- Background Border. Compatible browsers: Chrome, Edge, Firefox, Opera, Safari. Responsive: yes. Dependencies:
Learn how to use CSS borders to add visual borders around web page elements. Explore different border-related properties such as style, width, color, radius, and image.
People also ask
How to specify a border in CSS?
What is a border property in CSS?
What is a border shorthand CSS property?
What is a border-style property?
If the border-style property has four values: border-style: dotted solid double dashed; top border is dotted; right border is solid; bottom border is double; left border is dashed; If the border-style property has three values: border-style: dotted solid double; top border is dotted; right and left borders are solid; bottom border is double