HTML StyleHTML 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: HTML Style colorThe color property is used to define the text color. Let's see a simple example of styling html tags by color property of css. Test it NowOutput: This is Green ColorThis is Red ColorHTML Style background-colorThe 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 Test it NowOutput: This is yellow backgroundThis is red backgroundHTML Style font-familyThe 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 Test it NowOutput: This is times new roman font familyThis is arial font family HTML Style font-sizeThe font-size property is used to define the text size of the HTML tag. Let's see an example of font-size property Test it NowOutput: This is 200% h3 tagThis is 200% p tag HTML Style text-alignThe 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 Test it NowIf 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 sideThis text is located at center side HTML5 doesn't support <center> tag which is supported in older version of HTML.Supporting Browsers
If you want to know more about HTML styling, you can read it on CSS tutorial. Next TopicHTML sub Tag |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India