Is a CSS property starting with a hash (#) valid?

前端 未结 6 440
抹茶落季
抹茶落季 2020-12-03 17:59

What does the following CSS do and is it valid?

h4 {
    width: 83%;
    #width: 75%;
}
6条回答
  •  [愿得一人]
    2020-12-03 18:43

    It is not valid. #width: 75%; is a syntax error, since # isn't used in CSS property names (although it is used in CSS selectors, to select elements with specific ids). Most browsers will ignore it (hopefully) and only the first rule will be applied.

    It might have been someone's attempt to write a CSS comment. This is the valid way: /*This is a comment*/

    Edit

    I would suggest using a CSS reset file to account for browser differences.

提交回复
热议问题