Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the Font and font Size in a textarea field

Using the following code sample:

<html>
<body>

<script language = "Javascript">

maxL=240;
var bName = navigator.appName;
function taLimit(taObj) {
 if (taObj.value.length==maxL) return false;
 return true;
}

function taCount(taObj,Cnt) { 
 objCnt=createObject(Cnt);
 objVal=taObj.value;
 if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
 if (objCnt) {
  if(bName == "Netscape"){ 
   objCnt.textContent=maxL-objVal.length;}
  else{objCnt.innerText=maxL-objVal.length;}
 }
 return true;
}
function createObject(objId) {
 if (document.getElementById) return document.getElementById(objId);
 else if (document.layers) return eval("document." + objId);
 else if (document.all) return eval("document.all." + objId);
 else return eval("document." + objId);
}
</script>
<font face="Arial" font size="2">
Maximum Number of characters for this text box is 240.</font><br>

<textarea onKeyPress="return taLimit(this)" onKeyUp="return taCount(this,'myCounter')" name="Message" rows=6 wrap="physical" cols=42>
</textarea>
<br>
<font face="Arial" font size="2">
You have <B><SPAN id=myCounter>240</SPAN></B> characters remaining 
for your message</font>

</body>
</html>

How do I change the font and font size in the textarea?

like image 981
Squarefinger Avatar asked Dec 20 '10 14:12

Squarefinger


1 Answers

Use CSS to define a style for the textarea element. For example:

textarea {
   font-size: 20pt;
   font-family: Arial;
} 

Note that there are three ways to add CSS to your website -- you can use an external stylesheet, an internal stylesheet, or inline styles (or a combination thereof).

Using an internal stylesheet might look like this:

<head>
<style type="text/css">
textarea {
   font-size: 20pt;
   font-family: Arial;
} 
</style>
</head>

<!-- rest of your code goes here... -->

See here for more information on styling textarea.

like image 51
Donut Avatar answered Sep 22 '22 16:09

Donut