pre{font-family:cursive;font-style:italic;font-size:xxx-small}
How to change pre
font size?
pre{font-family:cursive;font-style:italic;font-size:xxx-small}
How to change pre
font size?
While the font-size cannot be changed for text directly inside pre tags, you can always wrap that text in another element (a span, for example) and change the font size of that element.
For example (this is inline-styles, but could be put in CSS if you wanted):
<pre><span class="inner-pre" style="font-size: 11px">
Blah blah
Multiple lines and no br's!
Oh yeah!
</span></pre>
Your issue is probably due to Courer being used as the default font, if you set Courier New as the preferred font it should be fine.
The following works fine in both Firefox & IE
pre {
font-family: "courier new", courier, monospace;
font-size: 11px;
}
If you only need to change the font size once, you can write
<pre style="font-size: 10px">
...
</pre>
Take a look here:
You cannot change font size within a PRE element (and you cannot put a PRE element inside a FONT element, for example), but the BASEFONT element affects preformatted text, too.
One solution to fixing font size on pre
tags is to use:
pre
{
white-space: pre-wrap !important;
}
This fixes font sizes on mobile browsers, which cannot accurately determine the width of a pre
element.
Source: Font size of pre tag on mobile devices gets too big – a fix
Sorry for digging up an old issue. After searching high and low for "why browsers (specially mobile browsers) renders <pre>
tags text too small and unreadable", I found as suggested here, changing css font-size:
to em
helps. But the gotcha is em
for <pre>
effects size differently on desktop browser then on mobile brower. A clear discrepancy noticeable on android Samsung/Mozilla/Chrome increase in font-size less for the same value of em
then desktop browsers. The solution to this dilemma is to use %
instead of em
.
The css rule pre{font-size:200%;}
seems to enlarge <pre>
text more consistently (compare to other texts) on mobile browser as it does on desktop browser.
I think it can have something to do with the standard fonts supported by different browsers. Try your code in different browsers but remember IE is not W3 compatible.
I'm not sure if it's the right way to do it, but this worked for me in Firefox:
font: normal 11px Verdana, Arial, sans-serif;