IS 360 Declaring CSS Styles

Slides:



Advertisements
Similar presentations
Table, List, Blocks, Inline Style
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
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.
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
Making Things Look Nice: Visual Appearance and CSS CMPT 281.
Introduction to CSS. What is CSS? A CSS (cascading style sheet) file allows you to separate your web sites (X)HTML content from it’s style. Use your (X)HTML.
Lecture 5 Use Cases and Style Sheets
© 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.
Cascading Style Sheets. Slide 2 Lecture Overview Overview of Cascading Style Sheets (CSS) Ways to declare a CSS CSS formatting capabilities New features.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
CM143 Week 4 Introducing CSS. Cascading Style Sheets A definition for the style in which an element of the webpage will be displayed Border width, colour,
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,
Cascading Style Sheets (CSS) Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
Cascading Style Sheets (CSS) 1.  What is CSS?  Why CSS?  How to write a CSS? 2.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
MORE Cascading Style Sheets (The Positioning Model)
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.
CSS CSS is short for C ascading S tyle S heets. It is a new web page layout method that has been added to HTML to give web developers more control over.
IS 360 Declaring CSS Styles. Slide 2 Introduction Learn about the three ways to declare a style Inline / embedded / external Learn about the effect of.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
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,
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
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…
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.
IS 360 Understanding CSS Selectors. Slide 2 Types of Selectors There are different types of selectors Each has a different level of “specificity” An element.
1 Cascading Style Sheets
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.
CSS Cascading Style Sheets
4.01 Cascading Style Sheets
CSS: Cascading Style Sheets
Cascading Style Sheets
Madam Hazwani binti Rahmat
>> CSS Rules Selection
CX Introduction to Web Programming
Intro to CSS CS 1150 Fall 2016.
Cascading Style Sheets
CASCADING STYLE SHEET CSS.
CSS Applications to XML 19-Sep-18.
Website Design 3
Intro to CSS CS 1150 Spring 2017.
Second CSS Lecture Applications to XML
Software Engineering for Internet Applications
CS134 Web Design & Development
IS 360 Understanding CSS Selectors
The Internet 10/6/11 Cascading Style Sheets
Cascading Style Sheets
Cascading Style Sheets™ (CSS)
More CSS 22-Feb-19.
Web Design and Development
Part 1: Cascading Style Sheets
Chapter 6 Introducing Cascading Style Sheets
Web Design & Development
Cascading Style Sheets
Cascading Style Sheets
4.01 Cascading Style Sheets
CSS Applications to XML 20-May-19.
CSS Applications to XML 3-Jul-19.
Cascading Style Sheets™ (CSS)
Presentation transcript:

IS 360 Declaring CSS Styles

Introduction Learn about the three ways to declare a style Inline / embedded / external Learn about the effect of style declaration (cascading and inheritance)

Three ways to Declare a Style Inline The style is declared as part of the element declaration in the element’s body We really don’t use these much beyond testing Embedded Declared in the header of the Web page (<head>) element External The style is declared in a CSS page and used by the referencing HTML 5 page

Inline Style Declaration Set the style property of an element The property’s value contains a style declaration as mentioned in the previous slide

Inline Style Declaration (Example) The style attribute contains the style declaration <p style="padding: 10px; margin: 10px; font-family: ‘arial'; font-size: 10pt; font-weight: bold; border: thin groove #000080; width: 300px;" > Some text </p>

Embedded Style Sheets Embedded (internal) style sheets appear inside of a <style> element in the <head> section Multiple styles can be declared You can declare styles for common HTML elements such as <p> or anything else

Embedded Style Sheets (Syntax) Each style has the following syntax selector { property:value; property:value } selector contains the HTML 5 tag, class, id Note the <> characters do not appear The property:value syntax is the same as before Note that the {} characters enclose the style

Embedded Style Sheets Example

External Style Sheets Its just a file with an extension of .css Its contents are the same as the contents of a <style> element Reference an external style sheet using the <link> tag in an HTML document It’s possible to reference several external style sheets using multiple <link> tags

Using the <link> Tag The <link> tag has 3 important attributes rel – The relationship between the current document and the linked document Always “stylesheet” type – MIME type Always “text/css” href – The URL of the linked CSS Absolute and relative URLs are permitted

Using the <link> Tag (Example) Link to the CSS named using a relative directory reference <link rel=“stylesheet" href="MainStyle.css" type="text/css" />

Conflict Resolution It’s possible that an inline, internal, or external style element will conflict Styles are applied in the following order External style sheets Embedded style sheets Inline styles Thus, inline styles will override embedded and external styles Embedded styles will override external styles

What we Mean by Cascade The concept of cascade is tied to three concepts (rules) Importance Specificity Source order After these rules are applied, a weight is applied to each rule to determine which one takes precedence http://www.smashingmagazine.com/2010/04/07/css-specificity-and-inheritance/ Remember that an HTML 5 document is hierarchical When positioning, we often position an element relative to its parent element

Importance The !important declaration makes certain that a rule will be applied Use only in “special” circumstances

Specificity A measure how specific a selector is How many elements it could match Thousands: Score one in this column if  the declaration is inside a style attribute (such declarations don't have selectors, so their specificity is always simply 1000.) Otherwise 0. Hundreds: Score one in this column for each ID selector contained inside the overall selector. Tens: Score one in this column for each class selector, attribute selector, or pseudo-class contained inside the overall selector. Ones: Score one in this column for each element selector or pseudo-element contained inside the overall selector.

Specificity

Source Order If multiple selectors have the same importance and specificity, the last rule seen wins

What we Mean by Inheritance Some properties applied to an element will be applied to an element’s children Others are not Font-family and color are inherited You would not want to set the foreground color for every segment of text Border does not If you had a page border, everything inside a page would inherit (render) a border

Controlling inheritance The inherit value makes an element inherit a property The initial value forces the element to use the browser default if there is on unset resets the property to it’s natural inheritance value

Tutorial Following is a good tutorial of CSS cascading and inheritance https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Cascade_and_inheritance