Set the font of a <p> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:font


Set the font of a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<p id="myP" style="font:italic bold 30px Georgia,serif;">This is a paragraph.</p>

<button type="button" onclick="myFunction()">Return font</button>

function myFunction() {/*from   ww  w.  j a va  2  s  .  c om*/
    document.getElementById("myP").style.font = 'bold 10px';


Related Tutorials