Cascading style sheets use “id” or “class”

后端 未结 15 2518
夕颜
夕颜 2020-12-05 16:11

when styling specific html elements, i tend to always use the class attribute. the css code looks cleaner imo.

why do both exist which one should you use and when ?<

15条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 16:50

    ids

    #header
    #footer
    #sidebar
    #menu
    #content
    

    classes

    .important
    .warning
    .validationError
    .recent
    .outOfDate
    .inactive
    .weekDay
    .previous
    .next
    .first
    .last
    

提交回复
热议问题