Reset CSS display property to default value

前端 未结 6 2128
粉色の甜心
粉色の甜心 2020-11-22 08:46

Is it possible to override the display property with its default value? For example if I have set it to none in one style, and I want to override it in a different with its

6条回答
  •  清歌不尽
    2020-11-22 09:10

    No, it is generally not possible. Once some CSS (or HTML) code sets a value for a property on an element, there is no way to undo it and tell the browser to use its default value.

    It is of course possible to set a property a value that you expect to be the default value. This may work rather widely if you check the Rendering section of HTML5 CR, mostly reflecting what browsers actually do.

    Still, the answer is “No”, because browsers may have whatever default values they like. You should analyze what was the reason for wanting to reset to defaults; the original problem may still be solvable.

提交回复
热议问题