HTML Styles

Every HTML element has a default style (background color is white, text color is black, text-size is 12px …). Changing the default style of an HTML element, can be done with the style attribute.

Background Color

<body style=”background-color:gray”>

Font Family, Color, and Size

The font-family property defines the font to be used for an HTML element.
<h1 style=”font-family:verdana”>A heading</h1>
<p style=”font-family:courier new; color:red; fontsize:20px;”>A paragraph</p>

Text Alignment

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

Lets see an Example

<!DOCTYPE html>
<HTML lang=”en-US”>
<body style=”background-color:yellow”>
<h1 style=”font-family:verdana”>A heading</h1>
<p style=”font-family:courier new; color:red; fontsize:20px;”>A paragraph</p>
<h1 style=”text-align:center”>This is center align</h1>
</body>
</HTML>

6

Leave a Reply