INTERNET APPLICATIONS CPIT405 CSS Cascading Style Sheet Instructor: Omnia H. Alwazzan

Slides:



Advertisements
Similar presentations
Introduction to HTML & CSS
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem External Style.
Cascading Style Sheets
Today CSS HTML A project.
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
Building a Website: Cascading Style Sheets (CSS) Fall 2013.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Chapter 8 Creating Style Sheets.
Introduction to Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 4.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
4.01 Cascading Style Sheets
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Cascading Style Sheets (CSS) Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
CSS Style Rules Guang Tong, Zhan L;lo’p[ Css Style Rule Guang Tong Zhan Three ways to insert CSS 1 External style sheet 2 Internal style sheet 3 Inline.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving.
CSS: Cascading Style Sheets. 2 What are Style Sheets A style sheet is a mechanism that allows to specify how HTML (/XHTML/XML) pages should look The style.
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
CSS Netcentric. What is CSS O CSS stands for Cascading Style Sheets O Styles define how to display HTML elements O Styles were added to HTML 4.0 to solve.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
CSS Basic (cascading style sheets)
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Essentials of HTML Class 4 Instructor: Jeanne Hart
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
DIV, Span, CSS.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
Introduction to CSS. What is CSS? CSS ("Cascading Style Sheets") determines how the elements in our XHTML documents are displayed and formatted. By using.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
How to… Cascading Style Sheets. How to Insert a Style Sheet When a browser reads a style sheet, it will format the document according to it. There are.
CSS: Cascading Style Sheets Part II. Style Syntax.
IN THE DOCUMENT OBJECT MODEL, EACH LINE OF HTML IS AN ELEMENT (AN OBJECT), ABLE TO HAVE ATTRIBUTES, PROPERTIES AND VALUES. CSS TELLS THE BROWSER HOW TO.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 22, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Html: structure & content CSS: presentation & style A CSS Primer chapter 4.
CASCADING STYLE SHEET CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem.
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
Working with Cascading Style Sheets
4.01 Cascading Style Sheets
Madam Hazwani binti Rahmat
CASCADING STYLE SHEET CSS.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
MORE Cascading Style Sheets (The Positioning Model)
DynamicHTML Cascading Style Sheet Internet Technology.
What are Cascading Stylesheets (CSS)?
Cascading Style Sheets
Cascading Style Sheets™ (CSS)
DynamicHTML Cascading Style Sheet Internet Technology.
Chapter 6 Introducing Cascading Style Sheets
The Internet 10/20/11 CSS Layout
4.01 Cascading Style Sheets
Presentation transcript:

INTERNET APPLICATIONS CPIT405 CSS Cascading Style Sheet Instructor: Omnia H. Alwazzan

Cascading Style Sheets  Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language.

CSS  CSS is designed primarily to enable the separation of document content from document presentation, including elements such as the layout, colors, and fonts.  This separation can improve content accessibility, provide more flexibility and control in the specification of presentation characteristics, enable multiple pages to share formatting, and reduce complexity and repetition in the structural content.

CSS (cont.)  CSS specifies a priority scheme to determine which style rules apply if more than one rule matches against a particular element.

Ways of inserting a style sheet 1. External style sheet. 2. Internal style sheet. 3. Inline style.

Internal Style Sheet  An internal style sheet should be used when a single document has a unique style.  You define internal styles in the section of an HTML page, by using the tag.

Example 1 body {color:red;} h1 {color:#00ff00;} p.ex {color:rgb(0,0,255);} This is a text This is heading 1 This is an ordinary paragraph. Notice that this text is red. The default text-color for a page is defined in the body selector. This is a paragraph with class="ex". This text is blue.

Example 2 a {text-decoration:none; color:green;} visit our university web site KAU

Example 3 h1{background-color:#6495ed;} p{background-color:#e0ffff;} div{background-color:#b0c4de;} CSS background-color example! This is a text inside a div element. This paragraph has it's own background color. We are still in the div element.

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 tag. The tag goes inside the section.

Example 1. Make new external css file 2. Write the following css in it 3. Save the file with style.css 4.. Make an html file and write the following on it body{ background-color:yellow;} h1{font-size:36pt;} h2{color:blue;} p{margin-left:50px;}

Example (cont.) This header is 36 pt This header is blue This paragraph has a left margin of 50 pixels

Inline Styles  An 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 contain any CSS property.

Example Untitled 1 this is a bold heading

Remember? Ways of inserting a style sheet 1. External style sheet. 2. Internal style sheet. 3. Inline style.

CSS Syntax A CSS rule has two main parts: a selector, and one or more declarations The 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.

Example 1. Make new external css file 2. Write the following css in it 3. Save the file as style.css 4. Make an html file and write the following in it body{ background-color:yellow;} h1{font-size:36pt;} h2{color:blue;} p{margin-left:50px;}

Example (cont.) This header is 36 pt This header is blue This paragraph has a left margin of 50 pixels

CSS positioning  Allows you to position an element.  Positioning can be tricky sometimes! Decide which element to display in front! Elements can overlap!

CSS positioning  Allows you to position an element.  It can also place an element behind another, and specify what should happen when an element's content is too big.  Elements can be positioned using the top, bottom, left, and right properties.  There are four different positioning methods. 1. Static Positioning 2. Fixed Positioning 3. Relative Positioning 4. Absolute Positioning

Static Positioning  HTML elements are positioned static by default.  Static positioned elements are not affected by the top, bottom, left, and right properties.

Fixed Positioning  An element with fixed position is positioned relative to the browser window.  It will not move even if the window is scrolled:  Example: p.pos_fixed { position:fixed; top:30px; right:5px; }

Relative Positioning  A relative positioned element is positioned relative to its normal position. Example: h2.pos_left { position:relative; left:-20px; } h2.pos_right { position:relative; left:20px; }

Absolute Positioning  An absolute position element is positioned relative to the first parent element that has a position other than static.  If no such element is found, the containing block is. Example: h2 { position:absolute; left:100px; top:150px; }

Selectors  Selectors are patterns used to select the element(s) you want to style. Universal selector "*"  It matches the name of any element type.  It matches any single element in the document tree.  If the universal selector is not the only component of a simple selector, the "*" may be omitted.

Example HTML code: The Universal Selector We must emphasize the following: It's not a wildcard. It matches elements regardless of type. This is an immediate child of the division. CSS code: div * em

The selector div * em will match the following em elements:  “Universal” in the h1 element (* matches the )  “emphasize” in the p element (* matches the )  “not” in the first li element (* matches the or the )  “type” in the second li element (* matches the or the )  It won’t match the immediate element, since that’s an immediate child of the div element—there’s nothing between and for the * to match.

Example This rule set will be applied to every element in a document: Follow this link for more example about a selector * { margin: 0; padding: 0;}

Descendant selectors  A descendant selector is made up of two or more selectors separated by white space.  A descendant selector of the form "A B" matches when an element B is an arbitrary descendant of some ancestor element A.  For example, consider the following rules: h1 { color: red } em { color: green }  Although the intention of these rules is to add emphasis to text by changing its color, the effect will be lost in a case such as: This headline is very important

 We address this case by supplementing the previous rules with a rule that sets the text color to blue whenever an EM occurs anywhere within an H1: h1 { color: red } em { color: green } h1 em { color: blue } Selects all elements inside elements  The third rule will match the EM in the following fragment: This headline is very important

Child Selector  A child selector matches when an element is the child of some element.  A child selector is made up of two or more selectors separated by ">".  The following rule sets the style of all P elements that are children of BODY: body > P { line-height: 1.3 }  The following example combines descendant selectors and child selectors: div ol>li p  It matches a P element that is a descendant of an LI; the LI element must be the child of an OL element; the OL element must be a descendant of a DIV.

Adjacent sibling selectors  Adjacent sibling selectors have the following syntax: E1 + E2  The selector matches if E1 and E2 share the same parent in the document tree and E1 immediately precedes E2, ignoring non-element nodes (such as text nodes and comments).  Thus, the following rule states that when a P element immediately follows a MATH element, it should not be indented: math + p { text-indent: 0 }  The next example reduces the vertical space separating an H1 and an H2 that immediately follows it: h1 + h2 { margin-top: -5mm }  The following rule is similar to the one in the previous example, except that it adds a class selector. Thus, special formatting only occurs when H1 has class="opener": h1.opener + h2 { margin-top: -5mm }

Example This selector matches all p elements that appear immediately after h2 elements: What will happen if we apply the above selector to the following code? h2+p { : declarations } Heading The selector above matches this paragraph. The selector above does not match this paragraph.

Heading The selector above does not match this paragraph. Heading Lorem ipsum dolor sit amet. The selector above matches this paragraph. h2+p { : declarations } What about this one? And this one?

Image Orientation:  Specifies a rotation in the right or clockwise direction that a user agent applies to an image.  The image-orientation property provides a way to specify a rotation to be applied to an image. Syntax image-orientation: [value];

Example class { image-orientation: 90deg; }

Assignment 4 A. Write an xhtml and css code to design the following:

Assignment 4 (cont.) B. Write a xhtml and css code to design the following  Move the inline style sheet out of the above program to have one external style sheet.

Question to think of  If many html files refer to same single css file, and one of the html needs a different style for a particular object compared to other html files, what will be the solution?

Note(s)  You should submit your answer before 11:55 am to acadox website course CPIT405 (1 week for each assignment).  your Answer Folder should be named as:yourName_assignment4_405

We’re done! Thank you for listening