问题
I think this is a simple and a silly question. I have included a text area in my html script.
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.
回答1:
Yes, using the CSS font-family property, just like any other element.
The W3C has a CSS tutorial as does Mozilla
回答2:
You can just open your css file and write code as mentioned below
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.
回答3:
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>
回答4:
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;
来源:https://stackoverflow.com/questions/11094981/changing-the-font-of-text-area