Border Property in CSS

The CSS border property allows the user to specify the border width, style and color of an element's border. This property is essential in web designing because it allows the designer to design and beautify the elements. There are two syntax to define element border;

First

border: border-with border-style border-color;

Second

border-with: border with; border-style: style of the border; border-color: color of the border;

border-with

The border-with property is used to define the with of the border.Border with can be define in px, em, %, thin, medium, and thick.

border-color

The border-color property is used to define the color of the border.Border with can be define using transparent, color name, RGB, or HEX.

border-Style

The border-style property specifies what kind of border to display. There are many value of border-style it includes none,dashed, solid, double, grove, ridge, inset, and outset. To understand how this two syntax work, follow the instructions bellow.

Using the First Syntax

The code bellow will till us how the first syntax work. Copy the code bellow and save it as "index.html".
  1. <style>
  2. #first {
  3.         width: 100px;
  4.         height: 100px;
  5.         border: 1px solid red;
  6. }
  7. </style>
  8. <div id="first">First</div>

Using the Second Syntax

The code bellow will till us how the second syntax work. Copy the code bellow and paste in "index.html".
  1. <style>
  2. #secondsyntax {
  3.         width: 100px;
  4.         height: 100px;
  5.         border-with: 1px;
  6.         border-style: solid;
  7.         border-color: red;
  8. }
  9. </style>
  10. <div id="secondsyntax">Second</div>
Make sure you follow the instructions properly in order to run this tutorial.

Add new comment