Apply a class to a br tag?

后端 未结 10 1440
感情败类
感情败类 2021-02-06 21:10

Is the following valid HTML?


As an HTML element I can\'t see why it wouldn\'t be, but I don\'t think I\'ve eve

相关标签:
10条回答
  • 2021-02-06 21:55

    Sure, it's valid. A useful example would be if you wanted to visually add a little space after a line-break, without ending the paragraph. Or perhaps apply a background image. All sorts of styling options.

    0 讨论(0)
  • 2021-02-06 21:59

    a br tag doesn't produce a CSS box and hence little can be done with it.

    Only practical case is clear. i believe drupal used it at some time. interestingly CSS 1 spec. refrained from doing anything to br. http://www.w3.org/TR/REC-CSS1/#br-elements. no doubt applying some css on it doesn't invalidate the code but will cause little effect.

    this https://stackoverflow.com/a/899359/1043824 is a good discussion on the topic.

    0 讨论(0)
  • 2021-02-06 22:01

    Yes, you can add a class attribute to a <br> element. id as well if you want.

    0 讨论(0)
  • 2021-02-06 22:02

    Yes.

    See the specification.

    The class attribute applies to "HTML Elements" (which includes br elements).

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