How to prevent headings (

) from taking up more width than they need?

后端 未结 4 886
长发绾君心
长发绾君心 2020-12-29 20:30

If I define a heading like

, its width is set to 100% by default.

Is there a way to make sure its width is set to the smallest value possible

4条回答
  •  春和景丽
    2020-12-29 20:57

    You can give it display: inline. This will make it behave like any text element - the default for

    is display: block.

    There are other ways: float: left for example, but I find this the simplest and the one with the fewest side effects.

    Note that you will then probably have to add a
    to ensure a line break after the

    .

提交回复
热议问题