Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format text the javascript way

Status
Not open for further replies.

SudyZenzi

Technical User
Aug 11, 2002
9
HK
hello all!
I'm learning Javascript and want some help from you gurus.

Please see this example and then I'm able to rectify my problem.

>> document.write ("Welcome to Javascript")

I want to format the font color to &quot;red&quot; and the font face to &quot;impact&quot;. I can bold the string by writing (&quot;<b>Welcome to Javascript</b>&quot;). But how to change the font color and the face.

Your help is highly appreciated. Thanks in advance.

SudyZenzi
 
Do this:

document.write (&quot;<font color='red' face='impact'>Welcome to Javascript</font>&quot;)

Rick if(($question==&quot;has been bugging me&quot;
AND $answer==&quot;fixed the problem&quot;) OR $answer==&quot;really good post&quot;){
print(&quot;Star&quot;);
}else{
print(&quot;Thanks.&quot;);
}
 
hi Rick,

>>> Star <<<. I think you got my answer. Thanks pal...Take care :)

SudyZenzi

 
That will definitely work. But I think the font tag is depricated. I would use CSS to format the text.
for instance;
<html>
<head><STYLE type=&quot;text/css&quot;>
<!--
p {
font-family: Impact;
color: red
}
-->
</STYLE>
</HEAD><body>
<script language=&quot;JavaScript&quot;>
<!--
document.write (&quot;<p>Welcome to Javascript</p>&quot;)
-->
</script>
</body>
</html>
Just my opinion take it for what it's worth.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top