Scanner class Methods in Java

HTML style Attribute

style Attribute

We can format the web page or document using HTML. CSS is a standard for styling web pages, but sill we can use HTML attributes to format he text,paragraphs or other elements.
In HTML styles of elements can be set using style attribute The style is HTML attribute but the value we specify in style is CSS property-value written in CSS style.

Syntax: 
<tagname style="property:value;">

Here the tagname is the name of element like ,p ,h1 etc, style attribute then the CSS property and value. We write CSS property and value in ""(double quotes) to differentiate it from HTML code
You can write many properties in style attribute to be applied to element using a semicolon(;) separator.

We'll discuss some examples as follows.

HTML Background color

You can change the color of background using the CSS background-color and value within any HTML tag using  style attribute.

The example below illustrates this property:

Example: 
<div style="background-color: pink;"This text has a pink background .</div>
Result:


example of style attribute to set background color div element in html

HTML Text color

You can change the color of text using this  CSS color and value with any HTML tag.

The example below illustrates this property:

Example:
<div style="color: red;"> The text has red color .</div>
Result:

example of style attribute to set color of text in div element in html

HTML Fonts

You can change the font of text using this  CSS font-family and value with any HTML tag.

The example below illustrates this property:

Example:
<div style="font-family: Courier;"The text is in "Courier" font .</div>
Result:

setting font-family using style attribute in html example

HTML Font Size

Font size of html text can be set using CSS font-size property and value .

The example below illustrates this property:

Example:
<div style="font-size: 20px;"The font size of text is 20px .</div>
Result:

setting font-sizeusing style attribute in html example

You can use many formatting properties of CSS in HTML within style attribute.

Comments