How do I set border width with CSS?
前端 未结 7 1577
广开言路
广开言路 2020-12-05 22:15

Why does this work?

And this doesn\'t?

<
7条回答
  •  时光说笑
    2020-12-05 23:03

    The reason it didn't work is that despite setting the border-width and the border-color you didn't specify the border-style:

JS Fiddle demo.

It's usually better to define the styles in the stylesheet (so that all elements are styled without having to find, and change, every element's style attribute):

table {
    border-color: #000;
    border-width: 1px;
    border-style: solid;
    /* or, of course,
    border: 1px solid #000;
    */
}

JS Fiddle demo (Or using shorthand border notation).

提交回复
热议问题