Home » Web programming/HTML

HTML Styles

HTML Styles: In this tutorial, we are going to learn about the style attribute of the tags in HTML, how to add some more styles/properties on a tag using it in HTML?
Submitted by Shivang Yadav, on December 21, 2019

HTML style Attribute

The HTML style attribute is used to add some style or add some changes to the text in HTML. Style is adding some additional settings to make it look different from ordinary text.

In HTML the style attribute takes care of styling elements.

Syntax:

<tag style= "property1:value; property2:value; property3:value;.. "/>

This will add CSS you will learn to your tag for styling it.

You will learn about styles and CSS tags in CSS Tutorials. Here, we will cover only some of these styles by changing some text and web pages.

Changing font of text in HTML

The font-family property is used to change the font of text specified by the tag.

Example:

<!DOCTYPE html>

<html>

<body>
    <p style="font-family:courier;">
        I love to learn programming from Include Help
    </p>
</body>

</html>

Output

HTML Styles | Example 1

Changing text size in HTML

The font-size property is used to change the size of text specified by the tag.

Example:

<!DOCTYPE html>

<html>

<body>
    <p style="font-family:courier;font-size:50px">
        I love to learn programming from Include Help
    </p>
</body>

</html>

Output

HTML Styles | Example 2

Changing text color in HTML

The color property is used to change the color of text specified by the tag.

Example:

<!DOCTYPE html>

<html>

<body>
    <p style="font-family:'Monotype Corsiva';font-size:50px;color:#006969">
        I love to learn programming from Include Help
    </p>
</body>

</html>

Output

HTML Styles | Example 3

Changing background color in HTML

The background-color property is used to specify background color of the tag.

Example:

<!DOCTYPE html>

<html>

<body>
    <p style="font-size:50px;color:#006969;background-color:#00f400">
        I love to learn programming from Include Help
    </p>
</body>

</html>

Output

HTML Styles | Example 4

Changing alignment of text in HTML

The text-align property is used to change the size of text specified by the tag.

Example:

<!DOCTYPE html>

<html>

<body>
    <p style="font-size:50px;color:#006969;background-color:#00f400;text-align:center;">
        I love to learn programming from Include Help
    </p>
</body>

</html>

Output

HTML Styles | Example 5








Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.