Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: How to remove line spacing from PRE tag

Tags:

html

jlabel

When the text is displayed from the follwing HTML there is a large space between the two line. How do i remove that space?

<pre style="font-family:arial;color:191970;font-size:10px;line-height:.1;">
Line 1 with one tab at the end
</pre>
<pre style="font-family:arial;color:191970;font-size:10px;line-height:.1;">
Line 2 with one tab at the end
</pre>

Why i am using tag? I place 2 tabs at the end of each line thats why i am using this tag

like image 264
Jame Avatar asked Nov 01 '11 05:11

Jame


People also ask

How do you remove padding from pre tag?

You can try changing the default value of white-space for <pre> tag from pre to pre-line . pre-line Sequences of whitespace are collapsed.

How do I change the space between lines in HTML?

To create extra spaces before, after, or in-between your text, use the &nbsp; (non-breaking space) extended HTML character. For example, with the phrasing "extra space" using a double space, we have the following code in our HTML.

How do I reduce the line spacing between two lines in HTML?

It turns out that's pretty simple: just use the line-height CSS property and then apply it. I have an example below. Then, you can apply that CSS class to your HTML. Now, the space between the lines changes.


2 Answers

you are using two <pre/> tags for two lines. so you need to manage margine and paddings for the <pre/> tag. line-height is not enough. and remember to set the line-height in em values and set the initial font size and line-height at the document level as well.

like image 139
Chamika Sandamal Avatar answered Nov 14 '22 12:11

Chamika Sandamal


by default pre tag is displayed as block, that is the reason. To over come this use following code in CSS

 pre 
    {
    display: inline;
    }
like image 39
SCC Avatar answered Nov 14 '22 11:11

SCC