Suppose I have the following line of code in html, how to set the text color and size inside "MonitorInformation" DIV element in a programming way using Javascript in an easy way? Sorry for my stupid, I figured a long time but cannot figure out. :-(
<div id="MonitorInformation">Connecting...wait</div>
thanks in advance, George
You can use a <basefont> tag to set all of your text to the same size, face, and color. The font tag is having three attributes called size, color, and face to customize your fonts. To change any of the font attributes at any time within your webpage, simply use the <font> tag.
Use the String fontcolor() Method We can apply the fontcolor() method on any text string, and it returns the <font> HTML element with the color attribute.
To set the font color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property color.
var elem = document.getElementById("MonitorInformation"); elem.innerHTML = "Setting different HTML content"; elem.style.color = "Red"; elem.style.fontSize = "large";
var myDiv = document.getElementById("MonitorInformation");
myDiv.style.fontSize = "11px";
myDiv.style.color = "blue";
Take a look at the JavaScript Style Attributes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With