Sie sind auf Seite 1von 3

8/2/13

HTML Styles
Search w3schools.com: Select Language

HOME

HTML

C SS

JAVASC RIPT

JQUERY

XML

ASP.NET

PHP

SQL

MORE...

R EFER ENC ES

EXAMPLES

FO R UM

ABO UT

Get Certified
Study Web Technologies and get a diploma at w3schools.com

SHARE THIS PAGE

Like

76k

HTML Basic
HTML HOME HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Formatting HTML Links HTML Head HTML CSS HTML Images HTML Tables HTML Lists HTML Blocks HTML Layout HTML Forms HTML Iframes HTML Colors HTML Colornames HTML Colorvalues HTML JavaScript HTML Entities HTML URL Encode HTML Quick List HTML Summary HTML XHTML

HTML Styles - CSS


Previous
CSS (Cascading Style Sheets) is used to style HTML elements.

WEB HOSTING

Next Chapter

Best Web Hosting eUK Web Hosting UK Reseller Hosting Domain, Hosting & Email

Look! Styles and colors


M a n i p u l a t e C o l o r s , and more... T e x t B o x e s

WEB BUILDING
XML Editor - Free Trial! FREE Website BUILDER FREE Website C reator Best Website Templates

STATISTICS Try it yourself


Browser Statistics OS Statistics

Try it Yourself - Examples


Using styles in HTML How to add style information inside the <head> section. Link that is not underlined How to make a link that is not underlined, with the style attribute. Link to an external style sheet How to use the <link> tag to link to an external style sheet.

Display Statistics

Styling HTML with CSS


CSS was introduced together with HTML 4, to provide a better way to style HTML elements. CSS can be added to HTML in the following ways: Inline - using the style attribute in HTML elements Internal - using the <style> element in the <head> section External - using an external CSS file The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files. However, in this HTML tutorial we will introduce you to CSS using the style attribute. This is done to simplify the examples. It also makes it easier for you to edit the code and try it yourself. You can learn everything about CSS in our CSS Tutorial.

HTML5 News
HTML5 Intro HTML5 New Elements HTML5 Canvas HTML5 SVG HTML5 Drag/Drop HTML5 Geolocation HTML5 Video HTML5 Audio HTML5 Input Types HTML5 Form Elements HTML5 Form Attributes HTML5 Semantic HTML5 Web Storage HTML5 App Cache HTML5 Web Workers HTML5 SSE

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:

< ps t y l e = " c o l o r : b l u e ; m a r g i n l e f t : 2 0 p x ; " > T h i si sap a r a g r a p h . < / p >


To learn more about style sheets, visit our CSS tutorial.

HTML Media
HTML Media HTML Object HTML Audio HTML Video HTML YouTube

HTML Style Example - Background Color


The background-color property defines the background color for an element:

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

HTML Examples
HTML Examples HTML Quiz HTML5 Quiz HTML Certificate HTML5 Certificate

HTML References
HTML Tag List HTML Attributes

w3schools.com/html/html_css.asp

1/3

8/2/13
HTML Events HTML Canvas HTML Audio/Video HTML Doctypes HTML Colornames HTML Colorpicker HTML Colormixer HTML Character Sets HTML ASCII HTML ISO-8859-1 HTML Symbols HTML URL Encode HTML Lang Codes HTTP Messages HTTP Methods Keyboard Shortcuts Try it yourself Try it yourself: Background color the old way

HTML Styles
The background-color property makes the "old" bgcolor attribute obsolete.

HTML Style Example - Font, Color and Size


The font-family, color, and font-size properties defines the font, color, and size of the text in an element:

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 >

The font-family, color, and font-size properties make the old <font> tag obsolete.

HTML Style Example - Text Alignment


The text-align property specifies the horizontal alignment of text in an element:

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 = " 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

Internal Style Sheet


An internal style sheet can be used if one single document has a unique style. Internal styles are defined in the <head> section of an HTML page, by using the <style> tag, like this:

< 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 >

External Style Sheet


An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the <head> section:

< 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 >

HTML Style Tags


Tag <style> <link> Description Defines style information for a document Defines the relationship between a document and an external resource

Deprecated Tags and Attributes


In HTML 4, several tags and attributes were used to style documents. These tags are not supported in newer versions of HTML. Avoid using the elements: <font>, <center>, and <strike>, and the attributes: color and bgcolor.

Previous

Next Chapter

w3schools.com/html/html_css.asp

2/3

8/2/13

HTML Styles

Top 10 Tutorials
HTML Tutorial HTML5 Tutorial C SS Tutorial C SS3 Tutorial JavaScript Tutorial jQuery Tutorial SQL Tutorial PHP Tutorial ASP.NET Tutorial XML Tutorial

Top 10 References
HTML/HTML5 Reference C SS 1,2,3 Reference C SS 3 Browser Support JavaScript HTML DOM XML DOM PHP Reference jQuery Reference ASP.NET Reference HTML C olors

Examples
HTML Examples C SS Examples XML Examples JavaScript Examples HTML DOM Examples XML DOM Examples AJAX Examples ASP.NET Examples Razor Examples ASP Examples SVG Examples

Quizzes
HTML Quiz HTML5 Quiz XHTML Quiz C SS Quiz JavaScript Quiz jQuery Quiz XML Quiz ASP Quiz PHP Quiz SQL Quiz

Color Picker

Statistics
Browser Statistics Browser OS Browser Display

RE P O RT E RRO R

HO ME

TO P

P RI N T

FO RU M

A BO U T

A D V E RT I SE WI T H U S

W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use and privacy policy. C opyright 1999-2013 by Refsnes Data. All Rights Reserved.

w3schools.com/html/html_css.asp

3/3

Das könnte Ihnen auch gefallen