Академический Документы
Профессиональный Документы
Культура Документы
HTML Styles
Next Chapter
Try it yourself
Inline Styles
An inline style can be used if a unique style is to be applied to one single occurrence of an element. To use inline styles, use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example below shows how to change the text color and the left margin of a paragraph:
w3schools.com/html/html_css.asp 1/3
4/4/13
HTML Styles
Example
< ! D O C T Y P Eh t m l > < h t m l > < b o d ys t y l e = " b a c k g r o u n d c o l o r : y e l l o w ; " > < h 2s t y l e = " b a c k g r o u n d c o l o r : r e d ; " > T h i si sah e a d i n g < / h 2 > < ps t y l e = " b a c k g r o u n d c o l o r : g r e e n ; " > T h i si sap a r a g r a p h . < / p > < / b o d y > < / h t m l >
Try it yourself The background-color property makes the "old" bgcolor attribute obsolete. Try it yourself: Background color the old way
Example
< ! D O C T Y P Eh t m l > < h t m l > < b o d y > < h 1s t y l e = " f o n t f a m i l y : v e r d a n a ; " > Ah e a d i n g < / h 1 > < ps t y l e = " f o n t f a m i l y : a r i a l ; c o l o r : r e d ; f o n t s i z e : 2 0 p x ; " > Ap a r a g r a p h . < / p > < / b o d y > < / h t m l >
Try it yourself The font-family, color, and font-size properties make the old <font> tag obsolete.
Example
< ! D O C T Y P Eh t m l > < h t m l >
w3schools.com/html/html_css.asp 2/3
4/4/13
HTML Styles
< b o d y > < h 1s t y l e = " t e x t a l i g n : c e n t e r ; " > C e n t e r a l i g n e dh e a d i n g < / h 1 > < p > T h i si sap a r a g r a p h . < / p > < / b o d y > < / h t m l >
Try it yourself The text-align property makes the old <center> tag obsolete. Try it yourself: Centered heading the old way
< h e a d > < s t y l et y p e = " t e x t / c s s " > b o d y{ b a c k g r o u n d c o l o r : y e l l o w ; } p{ c o l o r : b l u e ; } < / s t y l e > < / h e a d >
< h e a d > < l i n kr e l = " s t y l e s h e e t "t y p e = " t e x t / c s s "h r e f = " m y s t y l e . c s s " > < / h e a d >
Previous
w3schools.com/html/html_css.asp
Next Chapter
3/3