×

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

What is a CSS File?

What is a CSS File and How to use it in Html? CSS: - CSS stands for Cascading Style Sheet. CSS is a file of style sheets that describe the presentation of...

4 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 Arrow

CSS Arrow The arrow of CSS is applied to insert an array with the tooltip. It can make a tooltip as any speech bubble. Also, this arrow can be illustrated in...

4 minutes read.

Combine Background Image with Gradient Overlay

With the help of CSS gradient, we can display smooth and straightforward transitions between two or more colours. We can add the background images by combining the gradient property with...

2 minutes read.

CSS Content Property

Content Property The content attribute produces dynamic content. It can be applied with any pseudo-element ::after and ::before. These CSS properties are entirely supported inside every browser and applied to include...

5 minutes read.

CSS 2d Transform

Transform property in CSS is used mainly for enhancing the effects and to animate the elements. Transform is an effect that changes the shape, size and position of an element. It helps...

6 minutes read.

CSS Font

CSS Font: CSS has font property, which makes the text more attractive. We can alter the entire look by changing font color, font size, font style, and much more. In...

5 minutes read.

CSS Text-Overflow

Introduction: The text-overflow property of CSS is used to format the text which is overflowing the boundaries of the container. This property helps user to clip the text, to display the...

5 minutes read.

CSS Word Wrap

Word Wrap in CSS: The word-wrap property in CSS is referred to break any lengthy word and wrap towards the next or following line. It is employed for preventing overflow...

1 minute read.

Grid Vs Flexbox in CSS

Grid: - CSS Grid Layout is a 2D grid-based matrix-based layout method with columns and rows that simplifies web pages created by eliminating the need for floats and placement. A grid layout, like...

4 minutes read.

CSS Loader

CSS Loader The loader is the animation that can alert a visitor regarding the loading of the page. We need to wait for some time. It will be helpful if any...

4 minutes read.

CSS Checkbox style

CSS Checkbox style: It is an element of HTML, which is used to get input from various users. It is difficult to style any checkbox. However, some elements make it...

6 minutes read.

CSS Button Style

CSS button style: Using CSS properties, we can easily modify the default BUTTON and enhance its appearances using simple graphic commands. TYPES OF BUTTON STYLE: - Program to change button using CSS ...

35 minutes read.

CSS Outline

CSS Outline: This CSS property is quite similar to the border property of CSS. It eases us to design an additional border around the element to obtain visual attention. The...

4 minutes read.

CSS Visibility

Visibility in CSS: This visibility property in CSS is employed to describe whether the components are visible or not. Note: An invisible component also grabs the space over the page. If...

2 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 Animation

CSS Animation: The animation property of CSS is applied to make animation over any webpage. It is used as the animation replacement made by JavaScript and Flash. Rules of CSS3 @keyframes The...

3 minutes read.

CSS z-index Property

CSS z-index: CSS z-index permits us to represent any visual hierarchy over a 3D plane that is the z-axis. This index can be applied to describe the positioned element’s stacking...

2 minutes read.

What is CSS used for

What is CSS used for? CSS stands for Cascading Style Sheet. CSS is a stylesheet language for web pages. It specifies how a document created in a markup language looks and...

4 minutes read.

Create a 3D text effect using HTML and CSS

A3D text effect is a beautiful and attractive part of a webpage. As a web page developer, it is crucial to know how to create a 3D text effect with...

3 minutes read.