style

The style attribute in HTML allows you to apply CSS styles directly to an element, providing a way to quickly style it without needing external or internal style sheets.

style attribute

The style attribute lets you apply CSS styles directly to an element. Although it's useful for quick adjustments, it's better to use external CSS files for better organization and easier maintenance.

Syntax

index.html
<element style="property: value; property: value;">

Example

This is a header

This is a paragraph.

index.html
<h1 style="color:blue;text-align:center;">This is a header</h1>
<p style="color:green;">This is a paragraph.</p>

Applicable to

The style attribute is a global attribute, meaning it can be used with any HTML element.

ElementsAttribute
All HTML elementsstyle

See also

Conclusion

The style attribute in HTML allows you to apply inline CSS directly to elements for quick styling. While it's useful for simple cases, it's recommended to use external stylesheets for better scalability and maintainability. This attribute can be applied to any HTML element.