Curriculum
Course: CSS
Login

Curriculum

CSS

CSS INTRODUCTION

0/1

CSS Selectors

0/1

CSS Comments

0/1

CSS Padding

0/1

CSS Box Model

0/1

CSS Combinators

0/1

CSS Pseudo-classes

0/1

CSS Pseudo-elements

0/1

CSS Dropdowns

0/1

CSS Image Gallery

0/1

CSS Image Sprites

0/1

CSS Counters

0/1

CSS Website Layout

0/1

CSS Specificity

0/1

CSS Math Functions

0/1
Text lesson

Border Sides

CSS Border – Individual Sides

From the examples provided on earlier pages, you’ve observed the ability to define distinct borders for each side.

In CSS, there exist individual properties for specifying each border direction (top, right, bottom, and left).

Example

{
  border-top-style: dotted;
  border-right-style: solid;
  border-bottom-style: dotted;
  border-left-style: solid;
}

Outcome:

Image

The example provided yields an identical outcome to this one:

 

Example

{
  border-style: dotted solid;
}

Here’s how it functions:

If the border-style property has four values:

  • border-style: dotted solid double dashed;

                   The top border is dotted.

                   The right border is solid.

                   The bottom border is double.

                   The left border is dashed.

If the border-style property has three values:

  • border-style: dotted solid double;

                     The top border is dotted.

                      The right and left borders are solid.

                      The bottom border is double.

If the border-style property has two values:

  • border-style: dotted solid;

                     The top and bottom borders are dotted.

                      The right and left borders are solid.

If the border-style property has one value:

  • border-style: dotted;

                      All four borders are dotted.

Example

/* Four values */
{
  border-style: dotted solid double dashed;
}

/* Three values */
{
  border-style: dotted solid double;
}

/* Two values */
{
  border-style: dotted solid;
}

/* One value */
{
  border-style: dotted;
}

 

The example above demonstrates the usage of the border-style property. However, it also functions similarly with border-width and border-color.