Change font of a textarea

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
lshaw
Forum Commoner
Posts: 69
Joined: Mon Apr 20, 2009 3:40 pm
Location: United Kingdom

Change font of a textarea

Post by lshaw »

I was wondering how you change the font of a textarea (just like the one i used to post this message :) )
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Change font of a textarea

Post by aravona »

this should work:

Code: Select all

<textarea name="text2" cols="100" rows="50" [color=#FF0000]style="font-family:Century Gothic;"[/color]>default</textarea>
Only put whatever fonts you want in it :)
lshaw
Forum Commoner
Posts: 69
Joined: Mon Apr 20, 2009 3:40 pm
Location: United Kingdom

Re: Change font of a textarea

Post by lshaw »

Thanks for the answer. I just assumed it wouldn't we that simple for some reason. :? Im sure I had tested it. I must seem really stupid :lol:
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Change font of a textarea

Post by aravona »

lol dont worry, if you dont seem stupid once in a while, your not human :D
User avatar
Tit for Tat
Forum Newbie
Posts: 3
Joined: Wed Feb 10, 2010 8:14 am
Location: Sweden

Re: Change font of a textarea

Post by Tit for Tat »

aravona wrote:this should work:

Code: Select all

<textarea name="text2" cols="100" rows="50" [color=#FF0000]style="font-family:Century Gothic;"[/color]>default</textarea>
Only put whatever fonts you want in it :)
Bad way of doing it. According to the W3C all styling should be done in the CSS file when possible.

Code: Select all

[color=#FF00BF]textarea[/color] {
font-family: [color=#0000FF]Century Gothic[/color];
font-size: [color=#0000FF]1em[/color];
}
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Change font of a textarea

Post by aravona »

Fair enough I'd probs do it that way but I just cut and paste the example from google. It still works, but its just not as tidy.
User avatar
Tit for Tat
Forum Newbie
Posts: 3
Joined: Wed Feb 10, 2010 8:14 am
Location: Sweden

Re: Change font of a textarea

Post by Tit for Tat »

aravona wrote:Fair enough I'd probs do it that way but I just cut and paste the example from google. It still works, but its just not as tidy.
No problem. Just one more notest to the topic starter. You will need to set alternative values as well for the "font-type", this because the fonts are not loaded from the server but from the users machine. Just using one font type could result in issues if the user does not have that font installed.

Read up on the issue here: http://www.thesitewizard.com/webdesign/ ... -use.shtml
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: Change font of a textarea

Post by daedalus__ »

most browsers will revert to the default font set in its configuration if the specified family can't be found.

nowadays you can embed fonts fairly reliably though :)
Post Reply