×

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 Text-align

Text-align The text-align property of CSS sets the table-cell box’s horizontal alignment or any block element. The text-align property is the same as the CSS property vertical-align but towards any horizontal...

1 minute read.

CSS Text-decoration

CSS Text-decoration: It is an essential property of CSS that is used to decorate the content of the text. It can add-on the lines above, under, and over the text....

3 minutes read.

How to use google fonts in CSS

Fonts: - Fonts are used to make our website look more beautiful. Choosing appropriate font according to the web design or layout is also important. Many typefaces are accessible in...

4 minutes read.

CSS Text Effects

Text Effects in CSS We can use distinct text effects used inside the HTML document. Few attributes can be applied to insert the text effects. We can also style various web documents...

5 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 Align

CSS Center Align Elements CSS center align is used to create align by using block element. You should specify margin: auto;properties. The element will take up the specified width and the remaining space....

2 minutes read.

Difference between HTML and CSS

HTML HTML stands for HyperText Markup Language and is used to create web pages and websites and web applications, which means we can create static web pages. Html is a scripting...

3 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.

Is CSS a programming language?

 A programming language is a set of grammatical rules and a vocabulary for commanding a machine to accomplish specified tasks. High-level languages like BASIC, C, C++, COBOL, Java, FORTRAN, Ada...

4 minutes read.

CSS Lists

CSS Lists: Several properties are available in CSS that are used to manage the lists. Lists are distributed as ordered and unordered kind of lists. The ordered lists provide the...

7 minutes read.

How to change the font in CSS

How to change the font in CSS? Professionals can't deny typefaces — how users organize and style text — if we want to completely customize the website's design. One may wish...

4 minutes read.

CSS Order

CSS Order CSS order property in CSS describes the flex item’s order inside the flex or any grid container. It is applied to order any flex item. Note: If any component is...

3 minutes read.

CSS Box-shadow

CSS Box-shadow This property is referred to include effects as shadow-like around an element’s frame. Syntax box-shadow: h-offset v-offset blur spread color |inset|inherit|none; Property values Following are the various property values which can be used...

3 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.

How to center a table in CSS

The table is used to store and arrange the data in tabular format. The data here can be of any form like text, image, links, etc. The table is made...

3 minutes read.

CSS Word-spacing

Word-spacing The work-spacing property of CSS is applied to manage the space among the words. We can decrease or increase the space among the words by the use of this property. It...

3 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 White Space Property

White Space in CSS The white-space CSS property describes how to show the content inside an element. This property is applied to manage a white space within an element. Values of White-space...

2 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 Vertical Align

Vertical Align The vertical align CSS property describes the cell box of the table and an inline alignment vertically. This property is a self-explanatory and an essential property in CSS. But,...

2 minutes read.