HTML style attribute
HTML style attribute gives style to the content using CSS properties.
<div style="width:600px; height:600px; background:color:lightgreen;">i am content block. I have been styled using style attribute.</div>
</>
i am content block. I have been styled using style attribute.
Attribute values
All possible values of style attributeThe value of this attribute contains CSS properties. The syntax to write properties in style attribute is given below.
<p style="attribute-name:attribute-value;">Here the content is styled.</p>
attribute-name is present with colons (:). And the value of this attribute is present with semi-colons (;).
The following are the common attributes to style text.
background-color: red; indicates the red background color.
color: gray; defines the color of text.
font-size: 18px; defines the size of text.
font-family: papyrus; defines the font-family of text.
<p style="background-color:lightblue; color:white; font-size:18px; font-family:papyrus;">Here the text is of gray color. The background color is red.</p>
Try</>
Related Tags
The tags that support style attributeThe style attribute can be applied on all HTML elements.
Next Previous
Was this article helpful?