Definition
The border
property in CSS is used to set the appearance of an element’s borders. It’s a shorthand property combining border-width
, border-style
, and border-color
. These values can be specified together in a single border
declaration, allowing for concise control over the border’s look and feel.
Example of How to Use border
Here’s a basic example demonstrating the use of the border
property:
HTML
This div has a red border.
Code
<style>
.my-element {
border: 2px solid red;
padding: 20px;
}
</style>
<div class="my-element">This div has a red border.</div>
In this example, the div
with the class .my-element
will display a solid red border that is 2 pixels thick.