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 (Inline CSS) styles directly to an individual HTML element.
Syntax
Example
In this CSS rule background-color: coral; font-size: 30px, background-color is the property that specifies the background color of the paragraph, and coral is the assigned value that sets the background to coral. Similarly, font-size is the property that specifies the font size of the paragraph, and 30px is the assigned value that sets the font size to 30px.
Try It Yourself
Change the Text Color
Using the color property, we can change the text color of a text-based element such as a paragraph or a heading. Let's try it with an easy example!
Example
Try It Yourself
Change the Font Size
The font-size property, used to change the text size of a text-based element such as a paragraph or a heading.
Example
Try It Yourself
Change the Background Color
Using background-color property we can easily change the background color of an HTML element. Let's know how works!