CSS Border Properties

CSSWeb DevelopmentFront End Technology

The CSS border property is used to define the border properties for an element. It is a shorthand for border-width, border-style and border-color. We can style individual sides using side-specific properties like border-top, border-right, etc.

Syntax

The syntax of CSS border property is as follows −

Selector {
   border: /*value*/
}

Example

The following examples illustrate CSS border property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
div {
   border-style: solid;
   margin: auto;
   padding: 5px;
   border-radius: 50%;
}
#main {
   height: 100px;
   width: 100px;
   border-left: 12px ridge goldenrod;
   border-right: 12px ridge goldenrod;
}
#main > div {
   line-height: 12px;
   height: 30px;
   width: 10px;
   padding: 27px 20px;
   border-top: 6px groove crimson;
   border-bottom: 6px ridge crimson;
}
</style>
</head>
<body>
<div id="main">
<div>i see you</div>
</div>
</body>
</html>

Output

This gives the following output −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
p {
   width: 60%;
   margin: auto;
   padding: 20px 45px;
   border-top-width: 1.4em;
   border-top-style: solid;
   border-top-color: violet;
   border-radius: 85px 85px 0 0;
   color: black;
   font-size: 1.3em;
   background-image: url("https://www.tutorialspoint.com/images/css.png");
}
</style>
</head>
<body>
<p>CSS is used to control the style of a web document in a simple way. It handles the look and feel part of a web page.</p>
</body>
</html>

Output

This gives the following output −


raja
Published on 06-Jan-2020 12:15:40
Advertisements