...

View Full Version : Problems re-formatting text nodes



Tandem
03-02-2006, 01:42 PM
Hello!
I want to change the font of a text node I've just created using appendChild but doesn't work the ways I've tried. Could you tell me how to do it?

var table=document.getElementById("table_name");
tbody = table.appendChild(d.createElement("tbody"));
var row = tbody.appendChild(d.createElement("tr"));
var cell =d.createElement('td');
var txt=document.createTextNode('Hello World!');
cell.appendChild(txt);
row.appendChild(cell);

I want to change the font to: <font size="2" face="Verdana, Arial, Helvetica, sans-serif">

thanks! :)

Kravvitz
03-02-2006, 05:19 PM
This is a bit old, but much of what it says is relevant -- What's wrong with the FONT element? (http://www.mcsr.olemiss.edu/~mudws/font.html)

Use CSS.
Adding a touch of style (http://www.w3.org/MarkUp/Guide/Style)
Learning CSS (http://www.w3.org/Style/CSS/learning)
CSS2 Specification (http://www.w3.org/TR/REC-CSS2/)

Tandem
03-03-2006, 03:56 PM
But, is there any way to change font style using DOM properties or attributes?
Something like: cell.style.face="Arial"

Thanks

Kravvitz
03-03-2006, 04:36 PM
Yes.

cell.style.fontFamily = 'Verdana, Arial, Helvetica, sans-serif';
cell.style.fontSize = '.8em';

Tandem
03-12-2006, 12:20 AM
Thanks A Lot :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum