sam
sam

Reputation: 10074

Specifying top and bottom border with one css rule

Is it possable to set the top and bottom borders with 1 css rule, in a similar way to how you can set margin: 10px 0; instead of having to write two separate rules as below.

border-bottom: 1px solid #333333; border-top: 1px solid #333333;

Upvotes: 0

Views: 620

Answers (3)

ralph.m
ralph.m

Reputation: 14345

You can get pretty close, such as:

border: solid #333;
border-width: 1px 0;

Upvotes: 0

dzumla011
dzumla011

Reputation: 612

The shortest way possible is to set a border for all sides, and then eliminate the ones you don't need, but it is not possible with one line.

So say you want to have borders everywhere except on the bottom, the shortest way is:

border: 1px solid #333;
border-bottom: 0;

Upvotes: 1

Nomad101
Nomad101

Reputation: 1698

you can use the shorthand notation found here: http://www.w3schools.com/css/css_border.asp

However if you do not want borders on the right and left sides there is no short hand for that, unfortunately.

Upvotes: 0

Related Questions