Transcription

CSS TutorialCSS BasicCSS HOMECSS IntroductionCSS SyntaxCSS Id & ClassCSS How ToCSS Tutorial« W3Schools HomeSave a lot of work with CSS!CSS SSCSSCSSCSSCSSBox ModelBorderOutlineMarginPaddingCSS CSSCSSIn our CSS tutorial you will learn how to use CSS to control thestyle and layout of multiple Web pages all at once.BackgroundsTextFontsLinksListsTablesCSS Box oatingAlignPseudo-classPseudo-elementNavigation BarImage GalleryImage OpacityImage SpritesMedia TypesAttribute SelectorsDon'tSummaryNext Chapter »CSS nge;text-align:center;}p{font-family:"Times New Roman";font-size:20px;}Try it yourself »CSS ExamplesCSS ExamplesCSS QuizCSS QuizCSS ExamCSS ce A to ZReference AuralWeb Safe FontsUnitsColorsColorvaluesColornamesPage 1 of 53http://www.w3schools.com/css/default.asp

CSS IntroductionCSS BasicCSS HOMECSS IntroductionCSS SyntaxCSS Id & ClassCSS How ToCSS ackgroundsTextFontsLinksListsTablesCSS Introduction« PreviousNext Chapter »What You Should Already KnowBefore you continue you should have a basic understanding of the following: HTML / XHTMLIf you want to study these subjects first, find the tutorials on our Home page.What is CSS?CSS Box ModelCSSCSSCSSCSSCSSBox ModelBorderOutlineMarginPaddingCSS loatingAlignPseudo-classPseudo-elementNavigation BarImage GalleryImage OpacityImage SpritesMedia TypesAttribute SelectorsDon'tSummaryCSS Examples CSS stands for Cascading Style SheetsStyles define how to display HTML elementsStyles were added to HTML 4.0 to solve a problemExternal Style Sheets can save a lot of workExternal Style Sheets are stored in CSS filesCSS DemoAn HTML document can be displayed with different styles: See how it worksStyles Solved a Big ProblemHTML was never intended to contain tags for formatting a document.HTML was intended to define the content of a document, like: h1 This is a heading /h1 p This is a paragraph. /p When tags like font , and color attributes were added to the HTML 3.2 specification, it started anightmare for web developers. Development of large web sites, where fonts and color informationwere added to every single page, became a long and expensive process.To solve this problem, the World Wide Web Consortium (W3C) created CSS.CSS ExamplesCSS QuizIn HTML 4.0, all formatting could be removed from the HTML document, and stored in a separateCSS file.CSS QuizCSS ExamAll browsers support CSS today.CSS ReferencesCSS Saves a Lot of Work!CSSCSSCSSCSSCSSCSSCSSCSSReferenceReference A to ZReference AuralWeb Safe FontsUnitsColorsColorvaluesColornamesCSS defines HOW HTML elements are to be displayed.Styles are normally saved in external .css files. External style sheets enable you to change theappearance and layout of all the pages in a Web site, just by editing one single file!Page 2 of 53http://www.w3schools.com/css/css intro.asp

CSS SyntaxCSS BasicCSS HOMECSS IntroductionCSS SyntaxCSS Id & ClassCSS How ToCSS ackgroundsTextFontsLinksListsTablesCSS Syntax« PreviousNext Chapter »Examples Look at Example 1 Look at Example 2CSS SyntaxA CSS rule has two main parts: a selector, and one or more declarations:CSS Box ModelCSSCSSCSSCSSCSSBox ModelBorderOutlineMarginPaddingCSS loatingAlignPseudo-classPseudo-elementNavigation BarImage GalleryImage OpacityImage SpritesMedia TypesAttribute SelectorsDon'tSummaryThe selector is normally the HTML element you want to style.Each declaration consists of a property and a value.The property is the style attribute you want to change. Each property has a value.CSS ExampleCSS declarations always ends with a semicolon, and declaration groups are surrounded by curlybrackets:p {color:red;text-align:center;}To make the CSS more readable, you can put one declaration on each line, like this:CSS ExamplesCSS ExamplesCSS QuizCSS QuizCSS ExamCSS ce A to ZReference AuralWeb Safe r:red;text-align:center;}Try it yourself »CSS CommentsComments are used to explain your code, and may help you when you edit the source code at alater date. Comments are ignored by browsers.A CSS comment begins with "/*", and ends with "*/", like this:/*This is a comment*/p{text-align:center;/*This is another comment*/color:black;font-family:arial;}Page 3 of 53http://www.w3schools.com/css/css syntax.asp

CSS Id and ClassCSS BasicCSS HOMECSS IntroductionCSS SyntaxCSS Id & ClassCSS How ToCSS ackgroundsTextFontsLinksListsTablesCSS Box ModelCSSCSSCSSCSSCSSBox ModelBorderOutlineMarginPaddingCSS loatingAlignPseudo-classPseudo-elementNavigation BarImage GalleryImage OpacityImage SpritesMedia TypesAttribute SelectorsDon'tSummaryCSS ExamplesCSS Id and Class« PreviousNext Chapter »The id and class SelectorsIn addition to setting a style for a HTML element, CSS allows you to specify your own selectorscalled "id" and "class".The id SelectorThe id selector is used to specify a style for a single, unique element.The id selector uses the id attribute of the HTML element, and is defined with a "#".The style rule below will be applied to the element with id }Try it yourself »Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.The class SelectorThe class selector is used to specify a style for a group of elements. Unlike the id selector, the classselector is most often used on several elements.This allows you to set a particular style for any HTML elements with the same class.The class selector uses the HTML class attribute, and is defined with a "."CSS ExamplesIn the example below, all HTML elements with class "center" will be center-aligned:CSS QuizCSS QuizCSS ExamCSS ce A to ZReference AuralWeb Safe r {text-align:center;}Try it yourself »You can also specify that only specific HTML elements should be affected by a class.In the example below, all p elements with class "center" will be center-aligned:Examplep.center {text-align:center;}Try it yourself »Do NOT start a class name with a number! This is only supported in Internet Explorer.Page 4 of 53http://www.w3schools.com/css/css id class.asp

CSS How toCSS BasicCSS HOMECSS IntroductionCSS SyntaxCSS Id & ClassCSS How ToCSS How To.« PreviousNext Chapter »When a browser reads a style sheet, it will format the document according to it.CSS ackgroundsTextFontsLinksListsTablesThree Ways to Insert CSSThere are three ways of inserting a style sheet: External style sheet Internal style sheet Inline styleCSS Box ModelCSSCSSCSSCSSCSSBox ModelBorderOutlineMarginPaddingExternal Style SheetAn external style sheet is ideal when the style is applied to many pages. With an external stylesheet, you can change the look of an entire Web site by changing one file. Each page must link tothe style sheet using the link tag. The link tag goes inside the head section:CSS loatingAlignPseudo-classPseudo-elementNavigation BarImage GalleryImage OpacityImage SpritesMedia TypesAttribute SelectorsDon'tSummaryCSS Examples head link rel "stylesheet" type "text/css" href "mystyle.css" / /head An external style sheet can be written in any text editor. The file should not contain any html tags.Your style sheet should be saved with a .css extension. An example of a style sheet file is shownbelow:hr {color:sienna;}p {margin-left:20px;}body {background-image:url("images/back40.gif");}Do not leave spaces between the property value and the units! "margin-left:20 px" (instead of"margin-left:20px") will work in IE, but not in Firefox or Opera.CSS ExamplesInternal Style SheetCSS QuizAn internal style sheet should be used when a single document has a unique style. You defineinternal styles in the head section of an HTML page, by using the style tag, like this:CSS QuizCSS ExamCSS ce A to ZReference AuralWeb Safe FontsUnitsColorsColorvaluesColornames head style type "text/css" hr {color:sienna;}p {margin-left:20px;}body {background-image:url("images/back40.gif");} /style /head Inline StylesAn inline style loses many of the advantages of style sheets by mixing content with presentation.Use this method sparingly!To use inline styles you use the style attribute in the relevant tag. The style attribute can containany CSS property. The example shows how to change the color and the left margin of a paragraph: p style "color:sienna;margin-left:20px" This is a paragraph. /p Page 5 of 53http://www.w3schools.com/css/css howto.asp

CSS How toMultiple Style SheetsIf some properties have been set for the same selector in different style sheets, the values will beinherited from the more specific style sheet.For example, an external style sheet has these properties for the h3 t;}And an internal style sheet has these properties for the h3 selector:h3{text-align:right;font-size:20pt;}If the page with the internal style sheet also links to the external style sheet the properties for h3will be:color:red;text-align:right;font-size:20pt;The color is inherited from the external style sheet and the text-alignment and the font-size isreplaced by the internal style sheet.Multiple Styles Will Cascade into OneStyles can be specified: inside an HTML element inside the head section of an HTML page in an external CSS fileTip: Even multiple external style sheets can be referenced inside a single HTML document.Cascading orderWhat style will be used when there is more than one style specified for an HTML element?Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet bythe following rules, where number four has the highest priority:1.2.3.4.Browser defaultExternal style sheetInternal style sheet (in the head section)Inline style (inside an HTML element)So, an inline style (inside an HTML element) has the highest priority, which means that it willoverride a style defined inside the head tag, or in an external style sheet, or in a browser (adefault value).Note: If the link to the external style sheet is placed after the internal style sheet in HTML head , the external style sheet will override the internal style sheet!Page 6 of 53http://www.w3schools.com/css/css howto.asp

CSS BackgroundHOMEHTMLCSSCSS BasicCSSCSSCSSCSSCSSHOMEIntroductionSyntaxId & ClassHow ToCSS StylingStyling BackgroundsStyling TextStyling FontsStyling LinksStyling ListsStyling TablesCSS Box ModelCSSCSSCSSCSSCSSBox ModelBorderOutlineMarginPaddingCSS loatingAlignPseudo-classPseudo-elementNavigation BarImage GalleryImage OpacityImage SpritesMedia TypesAttribute SelectorsDon'tSummaryCSS ExamplesCSS ExamplesCSS QuizCSS QuizCSS ExamCSS ce A to ZReference AuralWeb Safe ASPPHPSQLMORE.ReferencesExamplesCSS Background« PreviousNext Chapter »CSS background properties are used to define the background effectsof an element.CSS properties used for background effects: ackground-attachmentbackground-positionBackground ColorThe background-color property specifies the background color of an element.The background color of a page is defined in the body selector:Examplebody {background-color:#b0c4de;}Try it yourself »The background color can be specified by: name - a color name, like "red" RGB - an RGB value, like "rgb(255,0,0)" Hex - a hex value, like "#ff0000"In the example below, the h1, p, and div elements have different background colors:Exampleh1 {background-color:#6495ed;}p {background-color:#e0ffff;}div {background-color:#b0c4de;}Try it yourself »Background ImageThe background-image property specifies an image to use as the background of an element.By default, the image is repeated so it covers the entire element.The background image for a page can be set like this:Examplebody {background-image:url('paper.gif');}Try it yourself »Below is an example of a bad combination of text and background image. The text is almost notreadable:Page 7 of 53http://www.w3schools.com/css/css background.aspFo

CSS BackgroundExamplebody {background-image:url('bgdesert.jpg');}Try it yourself »Background Image - Repeat Horizontally or VerticallyBy default, the background-image property repeats an image both horizontally and vertically.Some images should be repeated only horizontally or vertically, or they will look strange, like ng');}Try it yourself »If the image is repeated only horizontally (repeat-x), the background will look .png');background-repeat:repeat-x;}Try it yourself »Background Image - Set position and no-repeatWhen using a background image, use an image that does not disturb the text.Showing the image only once is specified by the background-repeat property:Examplebody{background-image:url('img tree.png');background-repeat:no-repeat;}Try it yourself »In the example above, the background image is shown in the same place as the text. We want tochange the position of the image, so that it does not disturb the text too much.The position of the image is specified by the background-position property:Examplebody{background-image:url('img position:top right;}Try it yourself »Background - Shorthand propertyAs you can see from the examples above, there are many properties to consider when dealing withbackgrounds.Page 8 of 53http://www.w3schools.com/css/css background.asp

CSS BackgroundTo shorten the code, it is also possible to specify all the properties in one single property. This iscalled a shorthand property.The shorthand property for background is simply "background":Examplebody {background:#ffffff url('img tree.png') no-repeat top right;}Try it yourself »When using the shorthand property the order of the property values are: ackground-attachmentbackground-positionIt does not matter if one of the property values are missing, as long as the ones that are presentare in this order.This example uses more advanced CSS. Take a look: Advanced exampleMore ExamplesHow to set a fixed background imageThis example demonstrates how to set a fixed background image. The image will not scroll with therest of the page.All CSS Background PropertiesThe number in the "CSS" column indicates in which CSS version the property is defined (CSS1 orCSS2).PropertyDescriptionValuesCSSbackgroundSets all the backgroundproperties in one inherit1background-attachmentSets whether a backgroundimage is fixed or scrolls with therest of the pagescrollfixedinherit1background-colorSets the background color of herit1background-imageSets the background image foran elementurl(URL)noneinherit1background-positionSets the starting position of abackground imagetop lefttop centertop rightcenter leftcenter centercenter rightbottom leftbottom centerbottom rightx% y%xpos yposinherit1background-repeatSets if/how a background imagewill be repeatedrepeatrepeat-xrepeat-yno-repeatinherit1« PreviousNext Chapter »Page 9 of 53http://www.w3schools.com/css/css background.asp

CSS TextCSS BasicCSSCSSCSSCSSCSSHOMEIntroductionSyntaxId & ClassHow ToCSS Text« PreviousTEXT FORMATTINGCSS StylingStyling BackgroundsStyling TextStyling FontsStyling LinksStyling ListsStyling TablesCSS Box ModelCSSCSSCSSCSSCSSBox ModelBorderOutlineMarginPaddingCSS loatingAlignPseudo-classPseudo-elementNavigation BarImage GalleryImage OpacityImage SpritesMedia TypesAttribute SelectorsDon'tSummaryNext Chapter »This text is styled with some of the text formattingproperties. The heading uses the text-align, text-transform,and color properties. The paragraph is indented, aligned, andthe space between characters is specified. The underline isremoved from the "Try it yourself" link.Text ColorThe color property is used to set the color of the text. The color can be specified by: name - a color name, like "red" RGB - an RGB value, like "rgb(255,0,0)" Hex - a hex value, like "#ff0000"The default color for a page is defined in the body selector.Examplebody {color:blue;}h1 {color:#00ff00;}h2 {color:rgb(255,0,0);}Try it yourself »For W3C compliant CSS: If you define the color property, you must also define the backgroundcolor property.CSS ExamplesText AlignmentCSS ExamplesThe text-align property is used to set the horizontal alignment of a text.CSS QuizText can be centered, or aligned to the left or right, or justified.CSS QuizCSS ExamWhen text-align is set to "justify", each line is stretched so that every line has equal width, and theleft and right margins are straight (like in magazines and newspapers).CSS ce A to ZReference AuralWeb Safe FontsUnitsColorsColorvaluesColornamesExampleh1 {text-align:center;}p.date {text-align:right;}p.main {text-align:justify;}Try it yourself »Text DecorationThe text-decoration property is used to set or remove decorations from text.The text-decoration property is mostly used to remove underlines from links for design purposes:Examplea {text-decoration:none;}Page 10 of 53http://www.w3schools.com/css/css text.asp

CSS TextTry it yourself »It can also be used to decorate line;}{text-decoration:blink;}Try it yourself »It is not recommended to underline text that is not a link, as this often confuse users.Text TransformationThe text-transform property is used to specify uppercase and lowercase letters in a text.It can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter ofeach word.Examplep.uppercase {text-transform:uppercase;}p.lowercase {text-transform:lowercase;}p.capitalize {text-transform:capitalize;}Try it yourself »Text IndentationThe text-indentation property is used to specify the indentation of the first line of a text.Examplep {text-indent:50px;}Try it yourself »More ExamplesSpecify the space between charactersThis example demonstrates how to increase or decrease the space between characters.Specify the space between linesThis example demonstrates how to specify the space between the lines in a paragraph.Set the text direction of an elementThis example demonstrates how to change the text direction of an element.Increase the white space between wordsThis example demonstrates how to increase the white space between words in a paragraph.Disable text wrapping inside an elementThis example demonstrates how to disable text wrapping inside an element.Vertical alignment of an imageThis example demonstrates how to set the vertical align of an image in a text.All CSS Text PropertiesThe number in the "CSS" column indicates in which CSS version the property is defined (CSS1 Sets the color of a textcolor1Sets the text directionltrrtl2line-heightSets the distance between linesnormalnumber1Page 11 of 53http://www.w3schools.com/css/css text.asp

CSS Textlength%letter-spacingIncrease or decrease the space between characters normallength1text-alignAligns the text in an elementleftrightcenterjustify1text-decorationAdds decoration to dentIndents the first line of text in an engthControls the letters in an e1normalembedbidi-override2vertical-alignSets the vertical alignment of an -bottomlength%1white-spaceSets how white space inside an element is handlednormalprenowrap1word-spacingIncrease or decrease the space between wordsnormallength1Page 12 of 53http://www.w3schools.com/css/css text.asp

CSS FontCSS BasicCSSCSSCSSCSSCSSHOMEIntroductionSyntaxId & ClassHow ToCSS Font« PreviousNext Chapter »CSS font properties define the font family, boldness, size, and the style of a text.CSS StylingStyling BackgroundsStyling TextStyling FontsStyling LinksStyling ListsStyling TablesDifference Between Serif and Sans-serif FontsCSS Box ModelCSSCSSCSSCSSCSSBox ModelBorderOutlineMarginPaddingCSS loatingAlignPseudo-classPseudo-elementNavigation BarImage GalleryImage OpacityImage SpritesMedia TypesAttribute SelectorsDon'tSummaryOn computer screens, sans-serif fonts are considered easier to read than serif fonts.CSS Font FamiliesIn CSS, there are two types of font family names: generic family - a group of font families with a similar look (like "Serif" or "Monospace") font family - a specific font family (like "Times New Roman" or "Arial")Generic familyFont familyDescriptionSerifTimes New RomanGeorgiaSerif fonts have small lines at the ends on somecharactersSans-serifArialVerdanaCourier NewLucida Console"Sans" means without - these fonts do not havethe lines at the ends of charactersMonospaceCSS ExamplesCSS ExamplesAll monospace characters has the same widthCSS QuizCSS QuizCSS ExamFont FamilyThe font family of a text is set with the font-family property.CSS ce A to ZReference AuralWeb Safe FontsUnitsColorsColorvaluesColornamesThe font-family property should hold several font names as a "fallback" system. If the browser doesnot support the first font, it tries the next font.Start with the font you want, and end with a generic family, to let the browser pick a similar font inthe generic family, if no other fonts are available.Note: If the name of a font family is more than one word, it must be in quotation marks, like fontfamily: "Times New Roman".More than one font family is specified in a comma-separated list:Examplep{font-family:"Times New Roman", Times, serif;}Try it yourself »For more commonly used font combinations, look at our Web Safe Font Combinations.Font StyleThe font-style property is mostly used to specify italic text.Page 13 of 53http://www.w3schools.com/css/css font.asp

CSS FontThis property has three values: normal - The text is shown normally italic - The text is shown in italics oblique - The text is "leaning" (oblique is very similar to italic, but less supported)Examplep.normal {font-style:normal;}p.italic {font-style:italic;}p.oblique {font-style:oblique;}Try it yourself »Font SizeThe font-size property sets the size of the text.Being able to manage the text size is important in web design. However, you should not use fontsize adjustments to make paragraphs look like headings, or headings look like paragraphs.Always use the proper HTML tags, like h1 - h6 for headings and p for paragraphs.The font-size value can be an absolute, or relative size.Absolute size: Sets the text to a specified size Does not allow a user to change the text size in all browsers (bad for accessibility reasons) Absolute size is useful when the physical size of the output is knownRelative size: Sets the size relative to surrounding elements Allows a user to change the text size in browsersIf you do not specify a font size, the default size for normal text, like paragraphs, is 16px(16px 1em).Set Font Size With PixelsSetting the text size with pixels, gives you full control over the text size:Exampleh1 {font-size:40px;}h2 {font-size:30px;}p {font-size:14px;}Try it yourself »The example above allows Firefox, Chrome, and Safari to resize the text, but not InternetExplorer.The text can be resized in all browsers using the zoom tool (however, this resizes the entire page,not just the text).Set Font Size With EmTo avoid the resizing problem with Internet Explorer, many developers use em instead of pixels.The em size unit is recommended by the W3C.1em is equal to the current font size. The default text size in browsers is 16px. So, the default sizeof 1em is 16px.The size can be calculated from pixels to em using this formula: pixels/16 emExampleh1 {font-size:2.5em;} /* 40px/16 2.5em */h2 {font-size:1.875em;} /* 30px/16 1.875em */p {font-size:0.875em;} /* 14px/16 0.875em */Try it yourself »Page 14 of 53http://www.w3schools.com/css/css font.asp

CSS FontIn the example above, the text size in em is the same as the previous example in pixels. However,with the em size, it is possible to adjust the text size in all browsers.Unfortunately, there is still a problem with IE. When resizing the text, it becomes larger than itshould when made larger, and smaller than it should when made smaller.Use a Combination of Percent and EmThe solution that works in all browsers, is to set a default font-size in percent for the body element:Examplebody {font-size:100%;}h1 {font-size:2.5em;}h2 {font-size:1.875em;}p {font-size:0.875em;}Try it yourself »Our code now works great! It shows the same text size in all browsers, and allows all browsers tozoom or resize the text!More ExamplesSet the boldness of the fontThis example demonstrates how to set the boldness of a font.Set the variant of the fontThis example demonstrates how to set the variant of a font.All the font properties in one declarationThis example demonstrates how to use the shorthand property for setting all of the font propertiesin one declaration.All CSS Font PropertiesThe number in the "CSS" column indicates in which CSS version the property is defined (CSS1 orCSS2).PropertyDescriptionValuesCSSfontSets all the font properties in cifies the font family for ifies the font size of smallerlargerlength%inherit1font-styleSpecifies the font style for es whether or not a text should be normaldisplayed in a small-caps fontsmall-capsinherit1font-weightSpecifies the weight of a font1normalboldbolderPage 15 of 53http://www.w3schools.com/css/css font.asp

CSS Fontlighter100200300400500600700800900inheritPage 16 of 53http://www.w3schools.com/css/css font.asp

CSS Styling LinksCSS BasicCSSCSSCSSCSSCSSHOMEIntroductionSyntaxId & ClassHow ToCSS Links« PreviousNext Chapter »Links can be styled in different ways.CSS StylingStyling BackgroundsStyling TextStyling FontsStyling LinksStyling ListsStyling TablesStyling LinksLinks can be style with any CSS property (e.g. color, font-family, background-color).Special for links are that they can be styled differently depending on what state they are in.The four links states are:CSS Box ModelCSSCSSCSSCSSCSSBox ModelBorderOutlineMarginPadding a:link - a normal, unvisited linka:visited - a link the user has visiteda:hover - a link when the user mouses over ita:active - a link the moment it is clickedExampleCSS loatingAlignPseudo-classPseudo-elementNavigation BarImage GalleryImage OpacityImage SpritesMedia TypesAttribute SelectorsDon'tSummaryCSS Examplesa:link {color:#FF0000;}/* unvisited link */a:visited {color:#00FF00;} /* visited link */a:hover {color:#FF00FF;} /* mouse over link */a:active {color:#0000FF;} /* selected link */Try it yourself »When setting the style for several link states, there are some order rules: a:hover MUST come after a:link and a:visited a:active MUST come after a:hoverCommon Link StylesIn the example above the link changes color depending on what state it is in.CSS ExamplesLets go through some of the other common ways to style links:CSS QuizText DecorationCSS QuizCSS ExamThe text-decoration property is mostly used to remove underlines from links:CSS ce A to ZReference AuralWeb Safe FontsUnitsColorsColorvaluesColornamesExamplea:link {text-decoration:none;}a:visited {text-decoration:none;}a:hover {text-decoration:underline;}a:active {text-decoration:underline;}Try it yourself »Background ColorThe background-color property specifies the background color for links:Examplea:link {background-color:#B2FF99;}a:visited {background-color:#FFFF85;}a:hover {background-color:#FF704D;}a:active {background-color:#FF704D;}Try it yourself »Page 17 of 53http://www.w3schools.com/css/css link.asp

CSS Styling ListsHOMEHTMLCSSCSS BasicCSSCSSCSSCSSCSSHOMEIntroductionSyntaxId & ClassHow ToXMLJAVASCRIPTASPPHP« PreviousSet different list item markers for ordered listsSet different list item markers for unordered listsSet an image as the list item markerCSS Box ModelIn HTML, there are two types of ating

CSS Tutorial « W3Schools Home Next Chapter » Save a lot of work with CSS! In our CSS tutorial you will learn how to use CSS to control the style and layout of multiple Web pages all at once. CSS Example body {background-color:#d0e4fe;} h1 {color:orange; text-align:center;} p {font-family:"Times New Roman"; font-size:20px;} Try it yourself .