HTML Styles

HTML Styles:

  • The HTML Style Attribute:-

Syntax:-

<tagname style=”property: value;”>

 

Background color:-

The CSS background-color property defines the background color for an HTML element.
Example:-
<!DOCTYPE html>
<html>
<body=”Background-color:Red;”>
<h1>This is heading</h1>
<p>This is paragraph</p>
</body>
</html>
  • background color for two different element:- 
Example:-
<!DOCTYPE html>
<html>
<body>
<h1 style=”Background color:Red;”>This is heading</h1>
<p style=”Background color:Blue;”>This is paragraph</p>
</body>
</html>

Text Color:-

The CSS color property defines the text color for an HTML element:

Example:-

<!DOCTYPE html>

<html>

<body>

<h1 style=”color:Red;”>This is heading</h1>

<p style=”color:Blue;”>This is paragraph</p>

</body>

</html>

Fonts:-

The CSS font-family property defines the font to be used for an HTML element:

Example:-

<!DOCTYPE html>

<html>

<body>

<h1 style=Font-family:verdana;”>This is heading</h1>

<p style=Font-family:courier;”>This is paragraph</p>

</body>

</html>

Text Size:-

The CSS font-size property defines the text size for an HTML element:

Example:-

<!DOCTYPE html>

<html>

<body>

<h1 style=”Font size:300%”>This is heading</h1>
<p style=”Font size:150%This is paragraph</p>
</body>
</html>

Text Alignment:-

The CSS text-align property defines the horizontal text alignment for an HTML element:

Example:-

<!DOCTYPE html>

<html>

<body>

<h1 style=”text -align:center;”>This is heading</h1>

<p style=”text align:centrer;”>This is paragraph</p>

</body>

</html>