How important is it to leave out the last ';' inside a set of CSS rules?

后端 未结 3 1289
伪装坚强ぢ
伪装坚强ぢ 2021-01-14 18:52

I\'ve had problems with Internet Explorer not applying the last property in a list of CSS properties. Is it necessary to leave out the last ; from a list of CSS

相关标签:
3条回答
  • 2021-01-14 19:27

    It doesn’t matter. Even Internet Explorer 6 will accept the redundant semi-colon at the end; your mistake must have been somewhere else.

    0 讨论(0)
  • 2021-01-14 19:28

    You don't need to include the last semi-colon. Nor do you have to exclude it. It's optional.

    From a maintenance point of view, I'd actually get into the habit of including after every property. Accidentally forgetting to put one one in when editing can cause some subtle errors.

    I am not aware of any issue with IE causing issues with missing semi-colon's - either that was an awful long time ago or there was some other issue that maybe lead you to believe that was the problem ;)

    0 讨论(0)
  • 2021-01-14 19:31

    Additional advice: Be absolutely sure you don't accidentally end a line with double semicolons, like

    .aStyle {
      background-color: #FFFFFF;;
      color: #000000;
    }
    

    This can have the extremely unhappy effect of negating every single style that comes after it on the page. It is not at all like an additional semicolon at the end of a line of Javascript, which has no effect whatsoever except to add a character to the page weight.

    0 讨论(0)
提交回复
热议问题