© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University

Slides:



Advertisements
Similar presentations
LIS650 lecture 4 Thomas Krichel today Advice CSS Properties –Box properties-- List properties –Table properties-- Classification properties.
Advertisements

LIS650 lecture 4 Thomas Krichel today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors.
Copenhagen, 6 December 2004 Modern CSS Principles Miruna Bădescu Finsiel Romania.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
Quiz #3 - CSS Lecture Code: Get Neighbors’ URLs for MP1
Cascading Style Sheets
Cascading Style Sheets
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Today CSS HTML A project.
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
Cascading Style Sheets Basics. Why use Cascading Style Sheets? Allows you to set up a series of rules for all pages in a site. The series may be changed.
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
CSS(Cascading Style Sheets )
1 Dreamweaver CS5 intermediate class by Cookie Setton Build a CSS website WITHOUT TABLES Just when you thought you were starting to understand HTML coding,
CSW131 Steven Battilana 1 CSW 131 – Chapter 5 (More) Advanced CSS Prepared by Prof. B. for use with Teach Yourself Visually Web Design by Ron Huddleston,
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.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University
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.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
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.
Cascading style sheets (CSS)
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
Tutorial 4: Using CSS for Page Layout. 2 Objectives Session 4.1 Explore CSS layout Compare types of floating layouts Examine code for CSS layouts View.
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.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
 Word doc for you to download › Link at the beginning of class › 10 Questions › Answers to be added inline  Post to Sakai when completed › No resubmits.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Lecture 2 - HTML and CSS Review SFDV3011 – Advanced Web Development 1.
Cascading Style Sheets Level 2. Course Objectives, Session 1 Level 1 Quick Review Chapter 8: Adding Graphics to Web Pages Chapter 9: Sprucing Up Your.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 8: Working with Style Sheets.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
© Anselm SpoerriDigital Media Production Digital Media Production Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University
Internet Technology Dr Jing LU Updated Dr Violet Snell / Dr Kalin Penev 1 Internet Technology (week 6)  Recap: Validating HTML  Page Layout.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
© Anselm SpoerriDigital Media Production Digital Media Production Digital Media Production Anselm Spoerri PhD (MIT) Rutgers University
CONTROLLING Page layout
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
 Add one element at a time  If it doesn’t do what you want, › Delete it › DON’T just keep piling on more items.
HTML 5 AND CSS Dr Mohd Soperi Mohd Zahid Semester /16.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Working with Cascading Style Sheets
Cascading Style Sheets™ (CSS)
Webpage layout using CSS
Web Development & Design Foundations with HTML5 7th Edition
Chapter 7 Page Layout Basics Key Concepts
Web Development & Design Foundations with HTML5 8th Edition
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Styles and the Box Model
Controlling Layout with Style Sheets
Second CSS Lecture Applications to XML
Web Development & Design Foundations with H T M L 5
More CSS 22-Feb-19.
The Internet 10/20/11 CSS Layout
Cascading Style Sheets™ (CSS)
Presentation transcript:

© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University

© Anselm SpoerriInfo + Web Tech Course Lecture 6 - Overview CSS –Cascade: Inheritance, Specificity and Location –Constructing Complex Selectors –Box Model –Floating Element | Positioning Elements: Absolutely Positioned Element –CSS Reset: CSS “Clean Slate”, HTML5 Backwards Compatible Demo of Exercise 3 Web Design –Basic Principles and Steve Krug’s Suggestions Testing & Debugging Web Pages  Check Easy Stuff First Lectures – Week 6 Content

© Anselm SpoerriInfo + Web Tech Course CSS: Cascade Cascade: Inheritance, Specificity and Location. Inheritance ‒ Html = Hierarchical Structure of the content Specificity ‒ The more specific the selector, the stronger the rule Location ‒ Rules that appear later have more weight

© Anselm SpoerriInfo + Web Tech Course CSS: Cascade Cascade: Inheritance, Specificity and Location. Inheritance ‒ Html = Hierarchical Structure of the content Elements are contained / appear with other elements (h1 resides inside div). ‒ Many properties, but not all, inherited by descendants of elements h1 is blue and has red border … blue is inherited but not red border by elements residing inside h1 element. ‒ Inherited rules are considered the most general of all and are overruled by any other rule. Specificity ‒ The more specific the selector, the stronger the rule h1 with class X rule will overrule h1 rule. ‒ The id attribute is considered the most specific.

© Anselm SpoerriInfo + Web Tech Course CSS: Cascade Cascade: Inheritance, Specificity and Location. Location ‒ Rules that appear later have more weight. Browser  External CSS  Internal CSS  Inline Style ‒ You can declare a rule to be more important than others by adding !important at the end of the rule. Summary In the absence of a rule, many styles are inherited from parent element to child. With two competing rules, the more specific the rule, the more weight or importance it has – regardless of its location. With two rules of equal specificity, the one that appears later wins. Note: Some CSS properties allow you to specify the URL of another file: if it is a relative URL, then it needs to relative to the external style sheet.

© Anselm SpoerriInfo + Web Tech Course CSS: External & Internal Style Sheets Linking to External Style Sheet ‒ Place inside tag. ‒ Linking to several external style sheets: the later ones take precedence over earlier ones (location principle). Creating Internal Style Sheet ‒ … Internal style sheet overrides external style sheets if and only if style tag comes after link tag. Applying styles locally is not recommended. To view other designer’s CSS code: view source code of Web page and look at internal style sheet and load URLs for external style sheets.

© Anselm SpoerriInfo + Web Tech Course CSS: Selectors Selector determines which elements the formatting will be applied to. Declarations define the formatting. Constructing Complex Selectors that apply formatting based on: ‒ type or name of element (e.g. tag) h1 {color: red;} ‒ context element is found h1 em {color: red;} h1.news {color: red;} div#gaudi p = any p element contained in div whose id is equal to gaudi ‒ class (.name) or id (#name) of an element strong.news {color: red;} div#gaudi {color: red;} ‒ pseudo-class tag:first-line tag:first-letter Specifying Groups of Elements: h1, h2 {color: red;}

© Anselm SpoerriInfo + Web Tech Course CSS: Selectors Summary and CSS Validator Combining Selectors 1.Define Context div#intro 2.Spell out Element’s Name div#intro p 3.Specify Class or Id of desired element div#intro p. firstP 4.Specify Pseudo-class or Pseudo-element div#intro p.firstP :first-letter example example CSS Validator

© Anselm SpoerriInfo + Web Tech Course Recap – CSS: Cascade Cascade: Inheritance, Specificity and Location. Inheritance example example –Html = Hierarchical Structure –Many properties, but not all, inherited by descendants of elements Specificity example example –The more specific the selector, the stronger the rule How do you create a specific CSS rule? –tag class (.name) id (#name)  context Location example example –Rules that appear later have more weight.  Inherit from Parent  The More Specific the rule, the More Weight  The one that Appears Later Wins.

© Anselm SpoerriInfo + Web Tech Course CSS – Box Model Box Model = every element is enclosed in Invisible Box Width and Height can be specified Padding = space surrounding content inside of box (all four sides can be specified separately) Border : can specify all four borders separately also specify border-style: type; border-width: n; border-color: color; Margin = invisible space around border of box (-top, -bottom,-left, -right, auto) w3schools: Box Model DemoBox Model Demo box-sizing: border-box; width, border and padding fall within Overflow : elements are not always contained in their boxes; can be: visible; hidden, scroll; auto (scroll appears when needed). If width, margin, border and padding don’t equal size of containing parent element  something’s got to give :)

© Anselm SpoerriInfo + Web Tech Course CSS – Floating Elements Making Elements Float so that they float in a sea of text float: left / right  element is on left / right  text flows on right / left. clear: left / right / both / none to keep elements from floating on left / right / both sides and none lets elements float on either side. clear property stops affected element from displaying until designated side is free. Add clear property to elements whose sides you want to be clear of floating elements. float :left clear: left float :left

© Anselm SpoerriInfo + Web Tech Course CSS – AP Element = AP Div AP Element = Absolutely Positioned Element = AP Div Specify exact coordinates with respect to: Body / AP parent element (position: absolute) Browser window (position: fixed) [not all browsers support it] then set top, right, bottom and/or left: value;  takes element out of “natural/normal flow” More Layout Control & Flexibility Layout flexibility like in print design Change visibility of AP Elements Nesting AP Elements Inherit properties from parent AP Element such as visibility AP elements can overlap  specify a stacking order (z-index) to position elements in 3D. Vertical-align: baseline/ middle / sub / super / top / bottom / text-top / text-bottom

© Anselm SpoerriInfo + Web Tech Course CSS – Position and Display Properties position property of an element position: static; default | appear in document / linear flow position: relative; positioned relative to its normal position position: absolute; positioned relative to 1 st non-static parent position: fixed; relative to browser window Learn CSS Positioning in 10 Steps display property of an element display: inline; Default. Displays element as inline element (like ) display: block; Displays element as block element (like ) display: none; Element will not be displayed (no effect on layout)

© Anselm SpoerriInfo + Web Tech Course CSS – Reset = “Clean Slate” + HTML5 Backwards Compatible CSS “Clean Slate” for html and html5 tags … { margin: 0; padding: 0; border: 0; font-size: 100%; font-weight: inherit; vertical-align: baseline; } HTML5 Reset for older browsers article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } HTML5 shiv for IE < 9 browsers

© Anselm SpoerriInfo + Web Tech Course Exercise 3 Exercise 3: CSS & Media – Enhance Information Resource with CSS and Media Create at least three pages (you can use content from Ex2) Develop External Style Sheet: controls appearance of pages –Have “CSS Reset” code at start of css file and HTML5 shiv in head –DIVs to control presentation: pageContent, mainContent, rightSidebar –Specify float and clear as needed –Specify borders, margins and padding as needed –HTML5: header, nav, main, article, figure, aside, footer –Specify float, clear as needed as well as padding etc as needed –Tags: p, h1, h2, a –Use sans-serif font + other Ex3 requirements Task: Design Compact and Visually Appealing Site Layout –Floating sidebar on the right –Image floating on left and enough text so that it flows around it –Footer does not float next to anything Create screencast related to page content Embed YouTube video and Screencast

© Anselm SpoerriInfo + Web Tech Course Exercise 3 – Demo Steps Step-by-Step files: Step 1 – Link to External CSS file Step 2 – Create DIVs to control presentation Step 3 – Create HTML5 to describe semantics Step 4 – Add Floating Sidebar Step 5 – Non-floating Footer and Floating Image Step 6 – Embed YouTube Video / Screencast

© Anselm SpoerriInfo + Web Tech Course Step 1 – Link to External CSS file Step 1 ‒ Download from ‒ “lec6.html” = css demo and “ex3styles.css” ‒ “ex3styles.css” file contains “CSS Reset” code ‒ Place /* before “Clean Slate” code and */ after it (code goes gray) ‒ Cut & Paste “lec6.html” Internal CSS Code into external CSS file ‒ Save ex3styles.css ‒ Save “lec6.html” As “ex3_step1.html” (page loses formatting) ‒ Create link to external CSS file in “ex3_step1.html” page ‒ ‒ page formatting is back

© Anselm SpoerriInfo + Web Tech Course Step 2 – Create DIVs to control presentation Step 2 ‒ Create DIVs to control presentation ‒ pageContent div already exists ‒ Create DIV with id=“mainContent” that is child of pageConent div ‒ mainContent div contains main element ‒ Create CSS rules for DIVs Specify CSS Internally in and then later move to external file ‒ CSS rule for id=“mainContent”

© Anselm SpoerriInfo + Web Tech Course Step 3 – Create HTML5 to describe semantics Step 3 ‒ Create HTML5 to describe semantics ‒ HTML5 elements in CSS demo: ‒ inside of DIV with id=“pageContent” ‒ element inside of DIV with id=“mainContent” ‒ element inside of DIV with id=“pageContent” ‒ Create HTML5 element inside of main element ‒ contains h1, p tags

© Anselm SpoerriInfo + Web Tech Course Step 4 – Add Floating Sidebar Step 4 ‒ Create DIV with id=“rightSidebar” ‒ Place this div in HTML hierarchy as child of “pageContent” div and before “mainContent” div ‒ Create CSS code for DIV with id=“rightSidebar” float:right; width:120px; height:100px; margin-top:20px; margin-left:10px; margin-bottom:10px; padding:5px; border-width:thin; border-style:solid; border-color:#C1F3BC; border-top: 20px solid #C1F3BC; ‒ Create HTML5 element in rightSidebar div

© Anselm SpoerriInfo + Web Tech Course Step 5 – Non-floating Footer and Floating Image on Left Step 5 ‒ Specify CSS code clear:both for “footer” element clear:both; margin-top:10px; ‒ Create HTML5 element and Insert Image Create element after h1 Insert image ‒ Specify class=“floatLeft” and apply to figure element float:left; margin-left: 5px; margin-right:10px; margin-top: 5px; margin-bottom:10px; border:medium; border-style:solid; border-color:black; ‒ Add enough text in paragraph so it wraps around image and sidebar

© Anselm SpoerriInfo + Web Tech Course Step 6 – Embed YouTube Video / Screencast Step 6 ‒ Create HTML5 element for Video / Screencast Create after opening paragraph ‒ Insert Table: Single Row and Two Cells ‒ Copy & Paste YouTube Embed Code into Cell Make sure to set width = 200 and height = 150 ‒ Copy & Paste Screencast into Cell Same steps as for YouTube video … embed on different page width and height specified in two places in code Next Steps Move Internal CSS code to External CSS file and remove comments for “clean slate” code and add HTML tags and specify CSS rules that are needed and format page to create your visual look Read Ex3 Requirements carefully

© Anselm SpoerriInfo + Web Tech Course Web Design – Basic Principles Alignment –Don't Mix Alignment Styles – Simplicity and Left-Aligned –Create Sufficient Left Margin –Constrain Total Width of Page Proxiamity –Related Things Close Together –Spatial Separation = Conceptual Separation Repetition & Consistency –Navigation, Graphics Color Coding, Typeface –Creates Ease of Use Contrast –Bigger, Bolder, Color, Spatial Distance –Guide the Eye

© Anselm SpoerriInfo + Web Tech Course Web Design – Steve Krug’s Suggestions Design for Scanning, not reading –Visual Hierarchy –Visual contrast - size, bold, color –Important things = Visually prominent –Break pages up into clearly defined areas –Related things = Spatially close, Nested –Don’t mix Alignment Styles : left-aligned text –Avoid “visual noise" –Leverage Conventions –Clear what's clickable –Use underline and/or color coding Make each click a “mindless” choice Cut ½ of words, then cut ½.

© Anselm SpoerriInfo + Web Tech Course Testing & Debugging Web Pages Before looking for a big problem, check common little problems :) Work incrementally Use process of elimination (use comments to make code active / inactive). Be careful about typos. In CSS, not sure if the problem is with the property or the selector, use a very simple declaration (color: red).

© Anselm SpoerriInfo + Web Tech Course Check Easy Stuff First - General Refresh browser so that latest file is shown Upload actual file and refresh browser so that latest file is shown Upload file in the correct location Make sure you save file Upload any related files: CSS, images, SWF etc. Make sure spelling of URL = spelling of filename. Test in multiple browsers Test on different computer than the one used to create the files

© Anselm SpoerriInfo + Web Tech Course Check Easy Stuff First – HTML & XHTML HTML Make sure you used correct spelling of tags Be careful about nesting and make sure you have closing tags Use HTML Transitional or HTML5 XHTML Make sure all attribute value enclosed in straight, not curly, quotes All elements have opening and closing tags (always put space before / for “ />” closing tag). XHTML is case-sensitive. Include # when specifying hexadecimal colors.

© Anselm SpoerriInfo + Web Tech Course Check Easy Stuff First – CSS Use colon (:) to separate your properties from value (color: red;). Complete each property-value pair with semicolon (;) No spaces between number and their units (16px). Close brackets. Don’t quote values. Use accepted value. Don’t forget closing tag. Make sure linked (X)HTML document to the proper CSS file(s). Watch the spaces and punctuation between selectors.

© Anselm SpoerriInfo + Web Tech Course Check Easy Stuff First – Testing Your Page 1.Validate (X)HTML and CSS. 2.Open in Browser 3.Formatting correct? 4.Hyperlinks work & correct? 5.CSS file referenced properly? 6.All images appear? If not, check the easy stuff first, especially spelling of filenames and don’t use spaces in filenames and saved as GIF or JPEG. 7.Upload files to server (and set permissions if needed). 8.View pages in different browsers. 9.Still Stuck  check for typos and check easy stuff first :)