<pre> tag not styling

时间:2016-07-07 02:08:05

标签: html css font-family pre

I want to style text on my website inside a <pre> tag but it will never work.

I have tried putting this in my CSS:

pre {
    font-family: Georgia;
}

And I have also tried putting it inline like this:

<pre style=”font-family: Georgia;”>

But none of these work, the font stays as monospace.

These things work here, but not on my website.

Why is this happening? If there is no solution, is there an alternative to the <pre> tag which lets me have line breaks?

3 个答案:

答案 0 :(得分:1)

我在一个页面上有两个样式表,这使得预文本是等宽的。删除其中一个修复了问题。

答案 1 :(得分:1)

你也可以使用类选择器用CSS设置预标签的样式 HTML代码

<pre class="code">  Text Here </pre>


CSS代码

.code { font-family: Georgia; background-color: #A8CBFF; }

您可以查看更多用途here

答案 2 :(得分:0)

尝试重要

pre {
    font-family: Georgia !important;
}


<pre style=”font-family: Georgia !important;”>