Code highlights logo


Setup and Syntax

Inline Styles

Inline styles are a type of CSS that allows you to apply styles directly to an HTML element using the style attribute. This attribute contains CSS code that applies styles only to that specific element.


1<tagname style="property: value;">

For example, suppose we have the following HTML code:

1<h1 style="color: blue;">Hello World</h1>

Here, the style attribute is used to apply the color property to the h1 element. The value of the color property is blue.

It's important to note that inline styles have the lowest priority in the CSS cascade. Hence, it's not recommended to use inline styles for large-scale styling of a webpage.

However, inline styles come in handy when making small, quick fixes or applying styles to a few elements. They are also useful when dynamically styling elements using Javascript.



In index.html, use inline styling to set the color of the first paragraph (the first <p> element) to red.

Sign up to start coding

Already have an account?

Sign In

Course content