How to line-break from css, without using
?

后端 未结 26 1542
攒了一身酷
攒了一身酷 2020-11-22 15:49

output:

hello
How are you

code:

hello
How are you

Ho

26条回答
  •  庸人自扰
    2020-11-22 16:21

    To make an element have a line break afterwards, assign it:

    display:block;

    Non-floated elements after a block level element will appear on the next line. Many elements, such as

    and

    are already block level elements so you can just use those.

    But while this is good to know, this really depends more on the context of your content. In your example, you would not want to use CSS to force a line break. The
    is appropriate because semantically the p tag is the the most appropriate for the text you are displaying. More markup just to hang CSS off it is unnecessary. Technically it's not exactly a paragraph, but there is no tag, so use what you have. Describing your content well with HTMl is way more important - after you have that then figure out how to make it look pretty.

提交回复
热议问题