Styling HTML Elements

Admin
0

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

<tagname style="property: value;">

Example

<p style="background-color: coral; font-size: 30px">I am a styled Paragraph!</p>

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

<p style="color: green;">My color is now GREEN!</p>

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

<p style="font-size: 30px;">I am a big text!</p>

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!

Example

<p style="background-color: yellow;">My background color is now YELLOW!</p>

Try It Yourself

Tags

Post a Comment

0Comments
Post a Comment (0)