TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

HTML Style

HTML Style tag with examples, forms, input, text, anchor, image, heading, marquee, textarea, paragraph, title, quotes, formatting, div, code etc.

<< Back to HTML

HTML Style

HTML Style is used to change or add the style on existing HTML elements. There is a default style for every HTML element e.g. background color is white, text color is black etc.

The style attribute can by used with any HTML tag. To apply style on HTML tag, you should have the basic knowledge of css properties e.g. color, background-color, text-align, font-family, font-size etc.

The syntax of style attribute is given below:

style= "property:value"

HTML Style color

The color property is used to define the text color.

Let's see a simple example of styling html tags by color property of css.

<h3 style="color:green">This is Green Color</h3>
<h3 style="color:red">This is Red Color</h3>
Test it Now

Output:

This is Green Color

This is Red Color


HTML Style background-color

The background-color property is used to define background color for the HTML tag.

Let's see an example of styling html tag by of css background-color property

<h3 style="background-color:yellow;">This is yellow background</h3>
<h3 style="background-color:red;color:white">This is red background</h3>
Test it Now

Output:

This is yellow background

This is red background


HTML Style font-family

The font-family property specifies the font family of the HTML tag.

Let's see an example of styling html tag by css font-family property

<h3 style="font-family:times new roman">This is times new roman font family</h3>
<p style="font-family:arial">This is arial font family</p>
Test it Now

Output:

This is times new roman font family

This is arial font family


HTML Style font-size

The font-size property is used to define the text size of the HTML tag.

Let's see an example of font-size property

<h3 style="font-size:200%">This is 200% h3 tag</h3>
<p style="font-size:200%">This is 200% p tag</p>
Test it Now

Output:

This is 200% h3 tag

This is 200% p tag


HTML Style text-align

The text-align property is used to define the horizontal text alignment for the HTML element.

Let's see an example of styling html tag by css text-align property

<h3 style="text-align:right;background-color:pink;">This text is located at right side</h3>
<p style="text-align:center;background-color:pink;">This text is located at center side</p>
Test it Now

If you want to put heading at center or left, use "text-align:center" or "text-align:left" respectively.

Output:

This text is located at right side

This text is located at center side

HTML5 doesn't support <center> tag which is supported in older version of HTML.

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
style attributeYesYesYesYesYes

If you want to know more about HTML styling, you can read it on CSS tutorial.

Next TopicHTML sub Tag




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf