Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cascading Style Sheets

Similar presentations


Presentation on theme: "Cascading Style Sheets"— Presentation transcript:

1 Cascading Style Sheets
CGS 3066: Lecture 3 Cascading Style Sheets

2 Term Project Maximum team size: 3
Teams and Topics are due on Monday 01/26/2015. Projects and assignments should be turned in on the CS department server, so please create your CS usernames. (CS username ≠ FSUID).

3 CSS 3 CSS stands for Cascading Style Sheets. Current Version: CSS 3.
Supported by most browsers Internet Explorer : 9 and higher Firefox: 15 or higher Chrome: 16 or higher Safari: 4 or higher Opera: 10 or higher

4 CSS - Intro Styles define how to display HTML elements.
Styles were added to HTML 4.0 to solve a problem. External Style Sheets can save a lot of work. External Style Sheets are stored in CSS files.

5 Why CSS? The original purpose of HTML was to combine the structure and content of the page into one document. When presentation elements began to be included in the document, it increased the complexity and reduced readability. Solution: Move the presentation elements elsewhere.

6 Why CSS? Separate the “style” elements from the documents and put it in a “style sheet”. Advantages: Styles can be changed easily. Document is more readable.

7 3 ways to do styling Inline Style Internal Style Sheets
Style elements are included as HTML attributes. Internal Style Sheets A <style> tag is used in the HTML document to specify the presentation elements. External Style Sheets A separate “.css” file is used as a part of your set of documents. It contains all the styling elements.

8 Inline CSS What little styling we’ve been doing so far.
Mixes content with presentation. Loses many of the advantages of a style sheet. Used very rarely (when very few elements require styling). Add the style attribute to the relevant tag. The style attribute can contain any CSS property.

9 Inline CSS example <h1 style="color:blue;margin-left:30px;"> This is a heading.</h1>

10 Internal CSS Used when the current document has a unique style.
A <style> tag is used under the <head> tag of the document to define the styles. The content of the <style> tag follows CSS syntax.

11 Internal CSS example <head> <style> body {
background-color: linen; } h1 { color: maroon; margin-left: 40px; </style> </head>

12 External CSS Used when a style is applied to many pages (like a theme). The look of the webpage can be changed by just changing one file. Each page must include a link to the style sheet with the <link> tag. The <link> tag goes inside the head section.

13 External CSS An external stylesheet is written as a separate file with a “.css” extension. Should go into the same relative path as the rest of the files (or can be referred by absolute path). The external stylesheet should not contain any HTML tags.

14 External CSS example mystyle.css body { background-color: lightblue; }
color: navy; margin-left: 20px;

15 External CSS example <head>
<link rel="stylesheet" type="text/css" href="mystyle.css"> </head>

16 Why “Cascading”? Multiple styles will cascade into one.
Styles can be specified: inside an HTML element inside the head section of an HTML page in an external CSS file

17 Cascading Order Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number one has the highest priority: Inline style (inside an HTML element) Internal style sheet (in the head section) External style sheet Browser default

18 Cascading example External Style sheet: Internal Style sheet: h1 {
color: navy; margin-left: 20px; } Internal Style sheet: color: orange;

19 Cascading example The final style for the h1 element will be a combination of the two according to the order of preference: color: orange; margin-left: 20px;


Download ppt "Cascading Style Sheets"

Similar presentations


Ads by Google