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

user782104 picture user782104 · Mar 14, 2013 · Viewed 175.3k times · Source

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?

Answer

Denys Séguret picture Denys Séguret · Mar 14, 2013
#testdiv {
   border-left: 1px solid;
}

See the MDN documentation on border.