createTextNode creates a Text node that has only one method: splitText. setAttribute is a DOM Core method implemented through the Element interface (i.e. not text nodes).
Generally, you should avoid setAttribute, as it has numerous quirks and setting the corresponding DOM property is faster and more reliable.
In any case, there is no fontSize attribute specified in HTML 4.01 for text nodes, so you cannot expect browsers to implement it. Text nodes inherit their style from their parent element, so if you want to set the font size of some text, wrap it in an element:
window.onload = function() { var span = document.createElement('span'); // Set DOM property span.style.fontSize = '200%'; span.appendChild(document.createTextNode('hey')); // Add to document document.body.appendChild(span); };
But in general, you better define the style in the class and attach it to the range.
Robg
source share