'EM' and 'P' element : HTML Style « HTML « JavaScript DHTML






'EM' and 'P' element

 
var elem = document.createElement("p");
var txt = document.createTextNode("My dog has fleas.");
elem.appendChild(txt);
document.body.appendChild(elem);

----------

var myEm, myP, txt1, txt2;
myEm = document.createElement("em");
txt1 = document.createTextNode("very");
myEm .appendChild(txt1);
myP = document.createElement("p");
txt1 = document.createTextNode("I am ");
txt2 = document.createTextNode(" happy to see you.");
myP.appendChild(txt1);
myP.appendChild(myEm);
myP.appendChild(txt2);
document.body.appendChild(myP);

           
       








Related examples in the same category

1.Paragraph Style
2.Make text bold by replaces it in the tree with an Element node
3.Using document create Style Sheet
4.Reading the canHaveChildren Property
5.Change the Text style Properties
6.Change html style
7.Using getBoundingClientRect()
8. Dynamically Updating Styles Using DHTML
9.Get Element style