Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use css to change <pre> font size

pre{font-family:cursive;font-style:italic;font-size:xxx-small} 

How to change pre font size?

like image 545
user289346 Avatar asked Mar 28 '10 05:03

user289346


People also ask

How do I change font size in pre tag?

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.

How do I change the default font size in CSS?

Set Font Size With Em 1em is equal to the current font size. The default text size in browsers is 16px.

Can you change font with CSS?

How to Change Font Type in HTML. To change font type purely with HTML, use the CSS font-family property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.


2 Answers

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> 
like image 118
Chris R Avatar answered Sep 22 '22 12:09

Chris R


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; } 
like image 22
Jon Freedman Avatar answered Sep 20 '22 12:09

Jon Freedman