×

CSS Border

CSS Border: The border property of CSS allows us to define the style, color, width, and radius of the element’s border. It is applied to various elements to set-up the border. Some essential properties of CSS border are as follows:

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

CSS border-style

A border-style CSS property is applied to define the type of border which we want to present inside various web pages. Some of the essential style values are permitted in this property, which is as follows:

  1. dotted: This value is used to specify the dotted border.
  2. dashed: This value is used to specify the dashed border.
  3. double: This value is used to define two borders along with a similar border-width value.
  4. groove: This value is used to specify the 3D grooved border. Its effect leans on the value of border-color.
  5. hidden: This value is used to specify the hidden border.
  6. inset: This value is used to specify the 3D inset border. Its effect leans on the value of border-color.
  7. none: This value is used to specify no border.
  8. out set: This value is used to specify the 3D out set border. Its effect leans on the value of border-value.
  9. ridge: This value is used to specify the 3D ridged border. Its effect leans on the value of border-color.
  10. solid: This value is used to specify the solid border.

This property of CSS may have one to four values. These values are left border, right border, top border, and the bottom border.

Example:

 <!DOCTYPE html>
  <html> 
  <head> 
  <style>   p.dotted {border-style: dotted;}   p.dashed {border-style: dashed;}   p.double {border-style: double;}   p.groove {border-style: groove;}   p.hidden {border-style: hidden;}   p.inset {border-style: inset;}   p.none {border-style: none;}   p.outset {border-style: outset;}   p.ridge {border-style: ridge;}   p.solid {border-style: solid;}   </style>
   </head>  
 <body>  
 <p class="dotted">Dotted   Border.</p>  
 <p class="dashed">Dashed   Border.</p> 
  <p class="double">Double   Border.</p> 
  <p class="groove">Groove   Border.</p>  
 <p class="hidden">Hidden   Border.</p> 
  <p class="inset">Inset Border.</p> 
  <p class="none">No Border.</p>  
 <p class="outset">Outset   Border.</p>  
 <p class="ridge">Ridge   Border.</p>  
 <p class="solid">Solid   Border.</p> 
  </body>  
 </html>    
CSS Border

CSS border-width

The CSS border-width property is applied on the web pages to fix the width of the border. It can be set-up in pixels. We can also use the three values to set-up the border-width property, which is as follows:

  • Thin
  • Medium
  • Thick

This property can’t be applied alone. It is always applied with other properties, if borders such as “border-style” are used for setting the border. Otherwise it will be useless.

Example:

 <DOCTYPE html>
   <html>
   <head>
   <style>   p.one {   border-style: solid;   border-width: 6px;   }   p.two {   border-style: solid;   border-width: medium;   }   p.three {   border-style: solid;   border-width: 2px;   }   p.four {   border-style: solid;   border-width: thick;   }   p.five {   border-style: solid;   border-width: 6px 10px; /*Some particular Side widths*/   }   </style>
   </head>   
<body> 
  <p class="one">This is an example to   set the border width.</p>
   <p class="two">This is an example to   set the border width.</p> 
 <p class="three">This is an example to   set the border width.</p> 
  <p class="four">This is an example to   set the border width.</p> 
  <p class="five">This is an example to   set the border width.</p> 
  </body>  
 </html>  
CSS Border

CSS border-color

The CSS border-color is applied to set the border’s color. Here, we can do this by one the following three types:

  • Name: This method is used to define a color name. For-example: “green”.
  • RGB: This method is used to define the color’s RGB value. For-example: “rgb(255,0,0)”.
  • HEX: This method is used to define the color’s hex value. For-example: “#ff0000”.
  • Transparent: When the color of the border is not fixed then it inherits through its element’s color property.

This property can’t be applied alone. It must be applied along with other properties like “border-style”.

Example:

 <!DOCTYPE html>
   <html>
   <head>
   <style>   p.color1 {   border-style: solid;   border-color: green;   }   p.color2 {   border-style: solid;   border-color: #ff0000;   }   p.color3 {   border-style: solid;   border-color: rgb(255,0,0);   }   p.color4 {   border-style: solid;   border-color: blue red green yellow;   }   </style>   </head>   
<body>   
<p class="color1">Green   Border.</p>   
<p class="color2">Red Border.</p>   
<p class="color3">Red Border.</p>   
<p class="color4">Mix color   Border.</p>   
</body>   
</html> 
CSS Border

Related Topics

CSS Selector

CSS Selector: There are some selectors used in CSS, which allows us to choose the content we wish to style. Various selectors are considered as the separation of the set...

5 minutes read.

CSS Page-break-before Attribute

Page-break-before Attribute As its name implies, the page-break-before property is applied to include page break before any element, at the time of printing any document. It adds the page break before...

5 minutes read.

CSS Image Gallery

Image galleries are used to display and store collections of images. Example Let’s discuss an example. CSS was used to create the following image gallery: Code is as follows: <html> <head> <style> div.gallery {   margin: 6px;   border: 1px...

5 minutes read.

CSS Filter

CSS Filter CSS filter is used to apply visual effects on the images, text, and other factors of the webpage. This filter property in CSS allows us to admit the effects like...

7 minutes read.

How to change background color in CSS

How to change background color in CSS? The background-color property in CSS would be used to specify the color of an element's background. As the element's background, it uses solid colors. The...

3 minutes read.

CSS Padding

CSS Padding: The padding property in CSS is addressed to describe the space among the element border and the element content.This property is quite different from the margin property of...

2 minutes read.

CSS Clip

CSS Clip The Clip property in CSS describes the element’s visible area. It applies over the elements which are absolutely positioned (position: absolute ;). Generally, it is used when an image...

2 minutes read.

CSS Comments

CSS Comments: Generally, comments in CSS are used to describe our code. Further, it will provide support to many users who are concerned with the code. Somewhat, these are ignored...

2 minutes read.

Untitled Reusable Block

  ...

1 minute read.

CSS: nth-selector

CSS nth selector can be used to match an element according to its position regardless of its parent’s type. Here, n can be any number, formula, or a keyword. These selectors...

2 minutes read.

CSS Important

CSS Important: CSS !important property is used to provide more importance, as compared to other CSS properties. The meaning of this property is “This is important.” This property enables CSS...

2 minutes read.

CSS @keyframes rule

CSS @keyframes rule It describes the rule of animation that depicts the properties of CSS for the components at every state along with the timeline. We may make the properties of complex...

4 minutes read.

CSS Links

CSS Link is used to create styled link. There are various ways to implement it. Styling Links Link can be styled with CSS properties like color, font-family, background etc. Example: <!DOCTYPE html>   <html>   <head>   <style>   a {       color: red;   }   </style>   </head>   <body>   <p><b><a href="https://www.tutorialandexample.com"    target="_blank">This is a link</a></b></p>   </body>   </html> Try Now There are four...

2 minutes read.

How to make smooth bounce animation using CSS

The smooth bouncing animation project is done with the help of HTML and CSS. This project gives so much fun and excitement to the users. What is HTML? The HTML or HyperText...

2 minutes read.

CSS Pseudo-elements

Pseudo-elements The pseudo-classes in CSS can be represented as any keyword which is connected to the selector that represents any selected element’s unique state. On the other hand, pseudo-elements can be...

6 minutes read.

CSS Color

CSS Colors: The CSS color property is used for setting the HTML element’s color. The color of the fonts and the color of the background can be set-up by using...

5 minutes read.

Internal CSS

What is CSS? CSS stands for Cascading Style Sheet.CSS is used to apply styling the HTML elements.With CSS user can add or change color, font-size and font-family. It also helps user...

4 minutes read.

CSS Opacity

The CSS Opacity property is used to set the clarity of the image. It is defined as degree and specify the transparency of an element. Note: Opacity value will be less...

1 minute read.

CSS Transition

CSS Transition The transitions in CSS are influenced, included to modify the component from one design to another, without the use of the JavaScript or Flash. We should describe two of the...

2 minutes read.

CSS Dropdowns

Dropdowns are one of the maximum crucial parts of an interactive internet site. CSS is a kind used to design the drop-down menus. A drop-down essentially is a group of...

5 minutes read.