如何语法<pre> element in html document

时间:2016-12-02 04:46:35

标签: html

I'm a beginner in HTML. I'm having problem in how to syntax my html doc. If I indent the second line inside the <pre> element, the pre formatted text doesn't appear correctly in the browser.

<body>
    <dl>
        <dt>thing 1</dt>
            <dd>Description text</dd>
            <dd><blockquote>
                <pre>Pre formated text first line.
                Pre formatted text second line</pre>
            </blockquote></dd>
    </dl>
</body>

The result looks like this

but if I want the text to appear correctly in the browser, my document becomes a mess.

<body>
    <dl>
            <dt>thing 1</dt>
                <dd>Description text</dd>
                <dd><blockquote>
                    <pre>Pre formated text first line.
Pre formatted text second line</pre>
                </blockquote></dd>
    </dl>
</body>

How to syntax the <pre> element correctly?

1 个答案:

答案 0 :(得分:0)

试试这个

<body>
<dl>
    <dt>thing 1</dt>
        <dd>Description text</dd>
        <dd><blockquote>
            <pre>
              Pre formated text first line.<br>
              Pre formatted text second line
            </pre>
        </blockquote></dd>
</dl>

添加CSS

pre {
white-space: normal;

}