How to set a border for an HTML div tag

前端 未结 9 847
予麋鹿
予麋鹿 2021-01-29 22:06

I am trying to define a border around a div tag in HTML. In some browsers the border does not appear.

Here is my HTML code:

9条回答
  •  醉话见心
    2021-01-29 22:40

    As per the W3C:

    Since the initial value of the border styles is 'none', no borders will be visible unless the border style is set.

    In other words, you need to set a border style (e.g. solid) for the border to show up. border:thin only sets the width. Also, the color will by default be the same as the text color (which normally doesn't look good).

    I recommend setting all three styles:

    style="border: thin solid black"
    

提交回复
热议问题