I am loading some content inside an iframe. I want this content to behave as-if it was inside a <pre>
tag - namely for it to respect line breaks. I am using javascript to set the style of the body element of this iframe.
I am wondering if it would be possible to set a particular style that will cause the body of this iframe to act like it's inside <pre/>
.
The <pre> tag defines preformatted text. Text in a <pre> element is displayed in a fixed-width font, and the text preserves both spaces and line breaks. The text will be displayed exactly as written in the HTML source code.
Center Align Elements To horizontally center a block element (like <div>), use margin: auto; Setting the width of the element will prevent it from stretching out to the edges of its container.
You need a wrapper like div class="wrap" which has position: relative . Then everything positioned absolutely inside this wrap will be absolute from top left inside the relative element.
The CSS id Selector The id of an element is unique within a page, so the id selector is used to select one unique element! To select an element with a specific id, write a hash (#) character, followed by the id of the element.
you can find the default setting or how they're suppose to be at http://www.w3.org/TR/CSS2/sample.html just apply the same style to the element you want to behave as a pre element and voila you're done
p.s. which is basically
pre{ white-space: pre ; display: block; unicode-bidi: embed }
If you're only interested in preserving line breaks but not whitespace then I suggest using:
body { white-space: pre-line; }
This will collapse multiple consecutive white space characters into one but preserve line breaks. The downside is that it's only supported in IE versions 8 and up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With