|
You can use the shortcut border property to set the width, style or colour for all the borders. The following example sets a solid red border that is 10 pixels wide: p {border: 10px solid red;} The width, style or colour applies to the borders in the following order: top, right, bottom and left. If you give a single value, the browser applies it to all four borders. If you enter two values, the first value applies to the top and bottom borders and the second to the left and right borders. If you enter three values, the first value applies to the top border, the second to the left and right borders and the third to the bottom border. Alternatively, you can set the width, style and colour separately: body {border-width: 10pt; border-style: solid; border-color: blue;} Here’s a list of the options you have:
Here are some examples of borders:
Instead of setting the border properties together, you can use the border-left, border-right, border-bottom and border-top properties set the width, style and colour of the left, right, bottom and top borders respectively. For example: body {border-left: 10px solid black; border-right: 10px double blue; border-bottom: 20px groove red; border-top: 20px ridge green;} So, you can have different widths, styles and colours for each of the borders if you want to. A bit over the top maybe. If you like typing, you can even specify the width, colour and style separately for each border. For example: body {border-left-style: solid; border-left-width: 10pt; border-left-color: black; border-right-style: dotted; . . border-top-color:red;} |
More information border |