Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a css border on one side only?

Tags:

css

border

For a given div I would like to only display a border on the left, right, top, or bottom side.

Currently I have the following, which puts a border on all sides:

#testdiv {    border: 1px solid; } 

What do I need to do in order to have a border only on the left side?

like image 286
user782104 Avatar asked Mar 14 '13 09:03

user782104


People also ask

How do you color one side of a border in CSS?

The border-right-color property sets the color of an element's right border. Note: Always declare the border-style or the border-right-style property before the border-right-color property. An element must have a border before you can change the color.


2 Answers

#testdiv {    border-left: 1px solid; } 

See the MDN documentation on border.

like image 190
Denys Séguret Avatar answered Oct 02 '22 09:10

Denys Séguret


If you want to set 4 sides separately use:

border-width: 1px 2em 5px 0; /* top right bottom left */ border-style: solid dotted inset double; border-color: #f00 #0f0 #00f #ff0; 
like image 44
otinanai Avatar answered Oct 02 '22 08:10

otinanai