Html Styles
This tutorial will help you to learn Html Styles and It is very easy to learn .You just follow my tutorial .Open your notepad and write code ,save it and see it in browser step by step.
Let's start.
Html style
is used by web developers to add styles to an element, for example color
, font, size
and more.
<!DOCTYPE html>
<html>
<body>
<p>This paragrah is without
syle.</p>
<p style="color:red;">this is
green color</p>
<p style="color:blue;">this is
red color</p>
<p style="font-size:50px;">font
siz is 50px.</p>
</body>
</html>
Browser result:
Style Attribute
The html style attribute is used to set the
style of an element
It has the following syntax:
<tagname style="property:value;">
Now we are
going to use this syntax and using some example will clear the concept.
Like we want
background color , text size ,font and text alignment in our paragraph.
Background Color
Background
color property is used to define background color for an element
<!DOCTYPE html>
<html>
<body
style="background-color:blue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Browser Result:
Fonts
Font-Family
property will be used to define different fonts for an html element.
<!DOCTYPE html>
<html>
<body>
<h1
style="font-family:courier;">This is a heading</h1>
<p
style="font-family:verdana;">This is a paragraph.</p>
</body>
</html>
Browser Result:
Text Size and Text Color
Font-Size Property
is used to define size for text and Color property for text color.
<!DOCTYPE html>
<html>
<body>
<h1
style="color:green;">This is a heading</h1>
<p
style="color:red;">This is a paragraph.</p>
<h1
style="font-size:250%;">This is a heading</h1>
<p
style="font-size:150%;">This is a paragraph.</p>
</body>
</html>
Browser Result:
Text Alignment
It is used
to define alignment for Html element. Property is text-align.
<!DOCTYPE html>
<html>
<body>
<h1
style="text-align:center;">This heading is aligned as
center.</h1>
<p
style="text-align:center;">This paragraph is aligned as
center.</p>
</body>
</html>
Browser Result:
I hope you like the post ,please don't hesitate to share my post to your friends. Thanks!!!
Comments
Post a Comment