Html 更改文本区域的字体

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11094981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:07:21  来源:igfitidea点击:

Changing The Font Of Text Area

htmltextarea

提问by Srivathsan

I think this is a simple and a silly question. I have included a text area in my html script.

我认为这是一个简单而愚蠢的问题。我在我的 html 脚本中包含了一个文本区域。

Is it possible to change the default font of the text area?

是否可以更改文本区域的默认字体?

The default one doesn't look good. I hope there is a way to change it.

默认的不好看。我希望有办法改变它。

回答by Quentin

Yes, using the CSS font-familyproperty, just like any other element.

是的,使用 CSSfont-family属性,就像任何其他元素一样。

The W3C has a CSS tutorialas does Mozilla

W3C和Mozilla都有一个CSS 教程

回答by Quentin

You can just open your css file and write code as mentioned below

您可以打开您的 css 文件并编写如下所述的代码

textarea  
{  
   font-family:"Times New Roman", Times, serif;  
   font-size: 12px;   
}

By following the above procedure, you can change the default property of any HTML tag you want.

按照上述过程,您可以更改所需的任何 HTML 标记的默认属性。

回答by Clark Superman

And the shortcut lazy version (not recommended):

还有快捷懒人版(不推荐):

    <textarea rows="5" cols="50" 
     style="font-family:Times New Roman;color:#003399;white-space:pre-wrap">Put your text here</textarea>

回答by Mishal Zaman

You can also use the font short hand version

您也可以使用字体简写版本

textarea
{
    font: 12px "Times New Roman", Times, serif;
}

The values:

价值:

font: font-style font-variant font-weight font-size/line-height font-family;