Inheritance CSS.

Slides:



Advertisements
Similar presentations
Copenhagen, 6 December 2004 Modern CSS Principles Miruna Bădescu Finsiel Romania.
Advertisements

Table, List, Blocks, Inline Style
Intro To Cascading Style Sheets By Mario Yannakakis.
Cascading Style Sheets (CSS). Cascading Style Sheets With the explosive growth of the World Wide Web, designers and programmers quickly explored and reached.
UNDERSTANDING CSS: THINKING INSIDE THE BOX The Cottage Garden The cottage garden is a distinct style of garden that uses an informal design, dense planting.
Cascading Style Sheets
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.
CSS CSS Precise Aesthetic Control. Cascading Style Sheets Though they can be put in HTML header, usually a separate page that the HTML links to Contains.
Lecture 5 Use Cases and Style Sheets
Today’s objectives  Element relations – tree structure  Pseudo classes  Pseudo elements.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
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.
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
CSS Basics LIS Webteam April 8, Why CSS? What’s wrong with HTML? Structure vs Style Early web design used hacks to style webpages with HTML – like.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
INTRODUCTION TO HTML5 CSS Styles. Understanding Style Sheets  HTML5 enables you to define many different types of content on a web page, including headings,
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.
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
Meet the Document Tree Your roadmap to Web Design.
CSS. HTML: Looking Back HTML dictates order, structure, and function Does very little to specify layout or visual rendering.
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.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
What is CSS? A set of style rules that tell the web browser how to present a web page or document. – In earlier versions of HTML, style characteristics,
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
Internet & World Wide Web How to Program, 5/e 1. 2.
WEB FOUNDATIONS CSS Overview. Outline  What is CSS  What does it do  Where are styles stored  Why use them  What is the cascade effect  CSS Syntax.
Introduction to CSS: Selectors
Cascading Style Sheets (CSS)
The Internet 10/11/11 Fonts and Colors
An Introduction to Cascading Style Sheets
CSS: Cascading Style Sheets
>> Introduction to CSS
Styles with Cascading Style Sheets (CSS)
Chapter 6 Cascading Style Sheets™ (CSS)
IS 360 Declaring CSS Styles
Cascading Style Sheets (CSS)
Text Elements.
Intro to CSS CS 1150 Fall 2016.
UNDERSTANDING CSS: THINKING INSIDE THE BOX The Cottage Garden The cottage garden is a distinct style of garden that uses an informal design, dense.
CSS.
Filezilla problems continuing
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Website Design 3
Text Elements.
Intro to CSS CS 1150 Spring 2017.
CSS.
Software Engineering for Internet Applications
Intro to CSS Mr. Singh.
CSS Style Sheets: Intro
IS 360 Understanding CSS Selectors
Cascading Style Sheets Color and Font Properties
Text Elements.
Document Object Model (DOM): Objects and Collections
Cascading Style Sheets
The Internet 10/6/11 Cascading Style Sheets
Cascading Style Sheets
Web Design and Development
Chapter 6 Introducing Cascading Style Sheets
Text Elements.
5.00 Apply procedures to organize content by using Dreamweaver. (22%)
Web Programming and Design
Text Elements.
CS332A Advanced HTML Programming
Presentation transcript:

Inheritance CSS

The Document Tree html head meta title body h1 p br b i Document trees are made from HTML elements. The document tree is just like a family tree.

Nesting Tags HTML tags don’t have to always contain just text – can contain other tags child A tag that contains other tags is called a parent. The tags contained in a parent tag are called children. parent

Descendent to b (and also to p and body and html) The Document Tree Ancestor to h1, p, br, b, and i html head meta title body h1 p br b i b and br are siblings An ancestor refers to any element that is connected but further up the tree. A descendent refers to any element that is connected but lower down the tree. A parent is an element that is connected & directly above an element in the document tree. A child is an element that is connected & directly below an element in the document tree. A sibling is an element that shares the same parent as another element. Child of body Descendent to b (and also to p and body and html) Parent to i

What is inheritance? Specific CSS properties are passed down to descendent elements. <em> element sits inside the <p> element The <em> element sits inside the <p> element. It is the child (and also the descendent) of the <p> element. In a browser, the <p> and <em> elements will both be colored red, even though the <em> element has not been specified in the style sheet. The <em> element has inherited the color property from the <p> element.

Why is inheritance helpful? Makes it easier for us! Otherwise, we would need to specify properties for all descendent elements.

Not All Properties are Inherited We haven’t messed with borders yet, but they create..well, a border… Imagine if the border property was inherited…YUCK! If all properties were inherited, authors would have to turn off unwanted CSS properties for descendent elements. This would be a pain. For example – if the border property was inherited, and we applied a border to the <p> element, both elements would have a separate border, which would be gross!

Luckily Borders are Not Inherited

Generally… Only properties that make our job easier are inherited I’ve highlighted the ones we have seen already!

The Special Case of Font Size Font-size is inherited in a different way from other properties Why? If it were not… If font-size were directly inherited, and the font-size value of 80% were to be inherited, the <em> would be sized to 80% of the <p> element…which is not what we want most likely. Thankfully this is not the case!!

How does it work? Descendent elements get calculated value – doesn’t keep scaling Keeps consistent size based on ancestors’ values for font-size

Use Inheritance for Efficiency Example: you can set the color, font-size and font-family on the body element. These properties will be inherited by all descendent elements. You can then override the properties as needed, specifying new values.