Can I set up tab stops in html5?

后端 未结 6 1558
北海茫月
北海茫月 2021-02-13 03:10

I would like to set up tab stops in html5 and be able to align text to them, just like in Word. For my application I can\'t use tables. Is there a way to do this? Do I have t

6条回答
  •  执念已碎
    2021-02-13 03:45

    You can use the CSS property p { text-indent:50px; }

    You can use css classes for each indent like

    h1 { text-indent: 10px; }
    h2 { text-indent: 14px; }
    h3 { text-indent: 18px; }
    p { text-indent: 20px; }
    p.notice { text-indent: 24px; }
    

    and do the HTML like this

    Heading 1

    Heading 2

    Heading 3

    Text 1

    Text 2

    Because you can only indent one line with this property there's another way to support multiline-indent:

    h1 { padding-left: 10px; }
    h2 { padding-left: 14px; }
    h3 { padding-left: 18px; }
    p { padding-left: 20px; }
    p.notice { padding-left: 24px; }
    

    And finally a fiddle.

提交回复
热议问题