tag breaks segments? I have an HTML page with some segments , and I gave them these attributes in an external CSS fold...">

HTML <br/"> tag breaks <code> segments?

I have an HTML page with some segments <code>, and I gave them these attributes in an external CSS folder:

code {

    background-color: f5f5ff;
    border-color : 7f7fbf;
    border-style : dashed;
    border-width : 1px;
    font-family  : courier new;
    margin-left  : 128px;
    padding      : 14px;
}

Whenever I put <br/>code in my segments, the code seems to jump to the left, ignoring the margin, and the filling spans the last line, for example, it was a whole new segment <code>located directly below it, right up to where the filling ends, and without left edge.

How to create a segment <code>with line breaks that displays all the code in one field, line breaks and everything until the end of the segment <code>, for example, it appears in the <code>preview of my message right now?

Here is an example of one of my <code>blocks / segments:

import math<br/>
def areaCircle(r)<br/>
return (math.pi * r) ^ 2

, , .

Chrome, FireFox; .

+3
4

<br /> white-space: pre display: block code.

code {
   display: block;
   white-space: pre;
}

jsFiddle.

+1

<pre> , <code>, .

: <pre> , .

:

<pre>
import math
def areaCircle(r)
return (math.pi * r) ^ 2
</pre>

To:

    <pre><!-- Extra whitespace generated -->
    import math
    def areaCircle(r)
    return (math.pi * r) ^ 2
    </pre>
+3
+1

, <br />, .

0

All Articles