Categories
Web development

CSS border-top-style Property

CSS border-top-style Property

The CSS border-top-style property settles the style of an element’s top border.

Demo:

Syntax:

border-top-style: dotted|dashed|solid|double|groove|ridge|inset|outset|none|hidden;

none (default) – defines no border.

hidden – a border is not visible.

dotted – defines a dotted border.

dashed – defines a dashed border.

solid – defines a solid border.

double – defines a double border.

groove – defines a 3D grooved border.

ridge – defines a 3D ridged border.

inset – defines a 3D inset border.

outset – defines a 3D outset border.

Example1:

A dotted top border:

<!DOCTYPE html>
<html>
<head>
<style>
div {
  border-top-style: dotted;
}

p {
  border-style: solid;
  border-top-style: dotted;
}
</style>
</head>
<body>

<div>A div element with a dotted top border</div>

<p>A paragraph with a dotted top border.</p>

</body>
</html>

Output:

A div element with a dotted top border

A paragraph with a dotted top border.


Example2:

A double top border:

<!DOCTYPE html>
<html>
<head>
<style>
div {
  border-top-style: double;
}

p {
  border-style: solid;
  border-top-style: double;
}
</style>
</head>
<body>

<div>A div element with a double top border</div>

<p>A paragraph with a double top border.</p>

</body>
</html>

Output:

A div element with a double top border

A paragraph with a double top border.


Enjoy coding!

Read also:

CSS border-bottom-style Property

CSS Outline