CSS Properties: How to set the style of the right border?

Go to Exercise page


HTML Code:

<!DOCTYPE html>
<title>How to set the style of the left border</title>
<style type="text/css"> 
h1  {border-style: solid;
     border-width: 3px;
h1.none {border-right-style: none;}
h1.dotted {border-right-style: dotted;}
h1.dashed {border-right-style: dashed;}
h1.solid {border-right-style: solid;}
h1.double {border-right-style: double;}
h1.groove {border-right-style: groove;}
h1.ridge {border-right-style: ridge;}
h1.inset {border-right-style: inset;}
h1.outset {border-right-style: outset;}
<h1 class="none">No right border</h1>
<h1 class="dotted">A dotted right border</h1>
<h1 class="dashed">A dashed right border</h1>
<h1 class="solid">A solid right border</h1>
<h1 class="double">A double right border</h1>
<h1 class="groove">A groove right border</h1>
<h1 class="ridge">A ridge right border</h1>
<h1 class="inset">An inset right border</h1>
<h1 class="outset">An outset right border</h1>

Live Demo:

See the Pen border-right-style-answer by w3resource (@w3resource) on CodePen.

See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
Yes Yes Yes Yes Yes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

Follow us on Facebook and Twitter for latest update.

HTML-CSS: Tips of the Day

How do I create an HTML table with a fixed/frozen left column and a scrollable body?

If you want a table where only the columns scroll horizontally, you can position: absolute the first column (and specify its width explicitly), and then wrap the entire table in an overflow-x: scroll block. Don't bother trying this in IE7, however...

HTML Code:

        <tr><th class="headcol">1</th><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
        <tr><th class="headcol">2</th><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
        <tr><th class="headcol">3</th><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
        <tr><th class="headcol">4</th><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
        <tr><th class="headcol">5</th><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>
        <tr><th class="headcol">6</th><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td></tr>

CSS Code:

table {
  border-collapse: separate;
  border-spacing: 0;
  border-top: 1px solid grey;

td, th {
  margin: 0;
  border: 1px solid grey;
  white-space: nowrap;
  border-top-width: 0px;

div {
  width: 500px;
  overflow-x: scroll;
  margin-left: 5em;
  overflow-y: visible;
  padding: 0;

.headcol {
  position: absolute;
  width: 5em;
  left: 0;
  top: auto;
  border-top-width: 1px;
  /*only relevant for first row*/
  margin-top: -1px;
  /*compensate for top border*/

.headcol:before {
  content: 'Row ';

.long {
  background: yellow;
  letter-spacing: 1em;

Live Demo:

See the Pen html css common editor by w3resource (@w3resource) on CodePen.