HTML creates the basic structure of a webpage. Applying styles is essential to make the webpage responsive and visually beautiful. In this chapter, we will show some easy examples of how CSS properties change HTML elements such as text color, background color, font size, borders, layout and more.
HTML Style Attribute
The style attribute in HTML is used to apply CSS styles directly to an individual HTML element. It allows you to define inline styles without needing an external or internal CSS file.
Syntax
<tagname style="property: value;">
Example1: Changing Background Color
<p style="background-color: coral;">This is a paragraph.</p>
Try It Yourself
Example2: Changing text Color
<p style="color: green;">This is a paragraph.</p>