CSS Border

Advertisements

Prev Tutorial Next Tutorial

CSS Border

The CSS border properties allow you to specify the style, size, and color of an Html element border. Following CSS border properties are used for Html elements,

  • border-style
  • border-width
  • border-color
  • border-radius

Border Style

The border-style property specifies what kind of border to display.

ValueDescription
noneIt is used for does not define any border.
dottedIt is used to define a dotted border.
dashedIt is used to define a dashed border.
solidIt is used to define a solid border.
doubleIt defines two borders with the same border-width value.
grooveIt defines a 3D grooved border. effect is generated according to border-color value.
ridgeIt defines a 3D ridged border. effect is generated according to border-color value.
insetIt defines a 3D inset border. effect is generated according to border-color value.
outsetIt defines a 3D outset border. effect is generated according to border-color value.

Example

<!DOCTYPE html>  
<html>  
<head>  
<style>  
p.none {border-style: none;}  
p.dotted {border-style: dotted;}  
p.dashed {border-style: dashed;}  
p.solid {border-style: solid;}  
p.double {border-style: double;}  
p.groove {border-style: groove;}  
p.ridge {border-style: ridge;}  
p.inset {border-style: inset;}  
p.outset {border-style: outset;}  
p.hidden {border-style: hidden;}  
</style>  
</head>  
<body>  
<p class="none">No border.</p>  
<p class="dotted">A dotted border.</p>  
<p class="dashed">A dashed border.</p>  
<p class="solid">A solid border.</p>  
<p class="double">A double border.</p>  
<p class="groove">A groove border.</p>  
<p class="ridge">A ridge border.</p>  
<p class="inset">An inset border.</p>  
<p class="outset">An outset border.</p>  
<p class="hidden">A hidden border.</p>  
</body>  
</html>

Output

No border.

A dotted border.

A dashed border.

A solid border.

A double border.

A groove border.

A ridge border.

An inset border.

An outset border.

Border Width

The border-width property is used to set the border width. It is set in pixels. You can also set the width of the border by using pre-defined values, thin, medium or thick.

Example: css border-color

<!DOCTYPE html>  
<html>  
<head>  
<style>  
p.para1w {  
    border-style: solid;  
    width:200px;
	border-color: green;  
}  
p.para2w {  
    border-style: solid;  
    width:100px;
    border-color: red;  
}   
</style>  
</head>  
<body>  
<p class="para1w">This is a solid red border</p>  
<p class="para2w">This is a solid green border</p>  
</body>  
</html>

Output

border-radius 50px

border-radius 10px

Border Color

This properties are used for set the color of Html elements border. There are three method to set the color of border.

  • Name: It specifies the color name. For example: "red".
  • RGB: It specifies the RGB value of the color. For example: "rgb(255,0,0)".
  • Hex: It specifies the hex value of the color. For example: "#ff0000".

Example: css border-color

<!DOCTYPE html>  
<html>  
<head>  
<style>  
p.para1 {  
    border-style: solid;  
    border-color: green;  
}  
p.para2 {  
    border-style: solid;  
    border-color: red;  
}   
</style>  
</head>  
<body>  
<p class="para1">This is a solid red border</p>  
<p class="para2">This is a solid green border</p>  
</body>  
</html>

Output

This is a solid red border

This is a solid green border

Border Radius

border-radius are used for give the radius for border, using this you can make a circle.

Example: css border-color

<!DOCTYPE html>  
<html>  
<head>  
<style>  
p.parar1 {  
    border-style: solid;  
    border-radius: 100%;  
    border-color: green;  
}  
p.parar2 {  
    border-style: solid;  
    border-radius: 50%; 
	height:100px;
	width:100px;
    border-color: red;  
}   
</style>  
</head>  
<body>  
<p class="parar1">This is a solid red border</p>  
<p class="parar2">This is a solid green border</p>  
</body>  
</html>

Output

border-radius 50px

border-radius 10px

Browser supported

Properties
borderYesYesYesYesYes

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements