DHTML AND JAVASCRIPT Genetic Computer School 2008 4-1 LESSON 4 CASCADING STYLE SHEET G H E F.

Slides:



Advertisements
Similar presentations
HIGH LEVEL OVERVIEW: CSS CSS SYNTAX CONSISTS OF A SET OF RULES THAT HAVE 3 PARTS: A SELECTOR, A PROPERTY, AND A VALUE. IT’S NOT NECESSARY TO REMEMBER THIS.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Cascading Style Sheets
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.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
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.
กระบวนวิชา 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.
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
Tutorial 3 Introducing Cascading Style Sheets. XP New Perspectives on Blended HTML, XHTML, and CSS2 Objectives Learn about Cascading Style Sheets Write.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
Web Design & Development Cascading Style Sheets (CSS)
Cascading Style Sheets Scripting with Style. CSS versus HTML  Ways to format in HTML –HTML Tag extensions –Converting Text to images –Page Layout with.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Cascading Style Sheet (CSS) Instructor: Dr. Fang (Daisy) Tang
Cascading style sheets - CSS
Lecture 7 Cascading Style Sheets (CSS) Boriana Koleva Room: C54
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
W EB S ITE L ECTURE C ASCADING S TYLE S HEETS. Cascading Style Sheets (CSS) Introduction CSS Objectives – Provide more control over web site content presentation.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
Cascading Style Sheets 1 Color and Backgrounds. Cascading Style Sheets 2 Color and Backgrounds Computer color basics Expression of color values using.
TECH2018 Multimedia and the Internet More about CSS and Page Layouts.
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,
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
Cascading style sheets (CSS)
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 09: Cascade Style Sheets - Spring 2011.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
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.
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
XP New Perspectives on XML Tutorial 5 1 TUTORIAL 5 CSS Tutorial – Carey ISBN
Chapter 12 Cascading Style Sheets: Part II The Web Warrior Guide to Web Design Technologies.
Doman’s Sections Information in this presentation includes text and images from
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 14, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
Cascading Style Sheets Chapter Four. What are they? A set of style rules that tell the web browser how to present a web page or document. Cascading Style.
CO1552 – Web Application Development Cascading Style Sheets.
Tutorial 5 Formatting with CSS. Objectives Session 5.1 – Evaluate why CSS styles are used – Determine where to write styles – Create an element selector.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Stylin’ with CSS Monday October 8 th and Tuesday October 9 th.
CSS Cascading Style Sheets. CSS Advantages Greater typography and page layout control Style is separate from structure Styles can be stored in a separate.
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
So far, we have looked at CSS selectors that correlate with HTML tags Now, we’ll see how you can define your own selectors using class and ID selectors.
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.
1 Web Development CSS (Cascading Style Sheet). 2 1.Setting rules for multiple elements To decrease the amount of typing for setting rules for multiple.
XHTML Formatting font with a style declaration. Formatting Font HTML uses the font tag to change size and family of font But… the font tag is being deprecated.
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,
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Developing Web Applications with HTML and CSS “Selectors and Properties”
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
CSS: Cascading Style Sheets Part II. Style Syntax.
Basic Webpage Design Cascading Style Sheet (CSS).
Tutorial 3 Designing a Web Page with CSS
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 CS428 Web Engineering Lecture 07 Font, Text & Background (CSS - II)
Cascading Style Sheets Robin Burke ECT 270. Outline CSS properties Fonts Alignment Color CSS selection selectors.
Internet & World Wide Web How to Program, 5/e 1. 2.
Cascading Style Sheets
Using Cascading Style Sheets Module B: CSS Structure
Cascading Style Sheets Color and Font Properties
Presentation transcript:

DHTML AND JAVASCRIPT Genetic Computer School LESSON 4 CASCADING STYLE SHEET G H E F

DHTML AND JAVASCRIPT Genetic Computer School Cascading Style Sheet, CSS A set of rules that determine how the styles are applied to the HTML tags in your documents.

DHTML AND JAVASCRIPT Genetic Computer School Three Types Of Style Sheets  Embedded  Inline  Link

DHTML AND JAVASCRIPT Genetic Computer School Embedded Style The style properties are included (within the tags) at the top of the HTML document. A style assigned to a particular tag applies to all those tags in this type of document.

DHTML AND JAVASCRIPT Genetic Computer School <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " transitional.dtd"> Embedded Style Write the Style here. Here are some texts, those are applied by style. Example: Embedded Style

DHTML AND JAVASCRIPT Genetic Computer School Inline Style The style properties are included throughout the HTML page. Each HTML tag receives its own style attributes as they occur in the page. The style properties are added to the HTML tag as the tag is entered.

DHTML AND JAVASCRIPT Genetic Computer School It is fine for documents in which you need to apply styles to only one or two elements, but you wouldn't want to do all that work when you have a lot of styles to add. When You Should Apply Inline Style

DHTML AND JAVASCRIPT Genetic Computer School The style properties are stored in a separate file. That file can be linked to any HTML document using a tag placed within the tags. Link Style

DHTML AND JAVASCRIPT Genetic Computer School <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " transitional.dtd"> Link Style Here are some texts, those are applied by style. Linked style sheets hold all the style properties in a separate file. Example: Link Style

DHTML AND JAVASCRIPT Genetic Computer School Cascading Precedence 1)Inline styles, which appear as attributes within the tag itself, are most important. 2) Embedded styles, which appear at the top of the HTML file, are applied next. 3)Linked styles, which appear in another file altogether, are applied last. Web browsers give precedence to the style that appears closest to the tag.

DHTML AND JAVASCRIPT Genetic Computer School Working With Fonts  font-family  font-size  font-variant  font-weight  short hand property- font

DHTML AND JAVASCRIPT Genetic Computer School Font-family Property A font family is simply a collection of fonts. Use this property to assign a list of specific and generic font families to any HTML block or element. Supply a list of specific fonts, separated from one another by commas, and end the list with a generic font that is to be used if none of the specific fonts are available Example: font-family: Helvetica, Arial, sans-serif; If the name of a font family that you want to specify contains embedded spaces, you will need to enclose that family name in quotation marks Example: font-family: “New Century Schoolbook”, Baskerville, serif;

DHTML AND JAVASCRIPT Genetic Computer School Font-size Property  Absolute Font Size  Relative Font Size

DHTML AND JAVASCRIPT Genetic Computer School Absolute Font Size  xx-small  x-small  small  medium  large  x-large  xx-large. Define absolute font sizes is to specify a length value in units. By using pixels to set font size, the visitors will be unable to resize the font using the browser setting in Internet Explorer.

DHTML AND JAVASCRIPT Genetic Computer School Relative Font Size It can be defined in three ways:  using the constants larger and smaller  using the relative measurement of ems  using a percentage value

DHTML AND JAVASCRIPT Genetic Computer School What is the base measurement? In the case of text that is contained directly in the body of a document, the base measurement is the browser’s default font size. Example: The default setting for text in a browser is 12 points A font-size setting of 1.5em Produces 18 point type For text inside other elements, the base measurement used by relative font sizing is the font-size of the element’s parent container, rather than the size of the element’s default font, as you may have expected.

DHTML AND JAVASCRIPT Genetic Computer School Font-style Property The font-style property determines whether the text inside an element is rendered in an italic, oblique, or roman (or normal) font style.

DHTML AND JAVASCRIPT Genetic Computer School font-variant property The font- variant property has only one effect: it determines whether text should be displayed in small- caps format. The only other value this property can take is normal.

DHTML AND JAVASCRIPT Genetic Computer School font-weight property Here weight refers to the boldness of the characters. The font-weight property can take two types of values: relative and absolutes. Relative values are bolder or lighter. Absolute values range from 100 (lightest) to 900 (boldest) in 100 units increment, and also include the shortcut names normal (= 400) and bold (=700).

DHTML AND JAVASCRIPT Genetic Computer School Shorthand property : font This short hand property allows you to set multiple font- related properties in one CSS declaration, separating the values by spaces from one another and using commas in multiple-value situations.

DHTML AND JAVASCRIPT Genetic Computer School Color Use style sheet rules to control the colour of any HTML element that can be displayed in colour.

DHTML AND JAVASCRIPT Genetic Computer School Elements That Can Be Displayed In Colour  Text  Headings  Page Backgrounds  Background Colour Of Text  Background Colour Of Headings  Borders  Links  Outlines

DHTML AND JAVASCRIPT Genetic Computer School Methods To Specify Colour Descriptive colour names System colour names RGB decimal values RGB hexadecimal values RGB percentage values color: blue; color: rgb(0, 0, 255); color: #0000ff; color: #00f; color: rgb(0%, 0%, 100%);

DHTML AND JAVASCRIPT Genetic Computer School The Selection Of Colours It becomes an important issue primarily in two situations:  when you have adjacent objects with coloured backgrounds and you want to avoid a clash  when you have coloured text on coloured backgrounds and you want to ensure readability

DHTML AND JAVASCRIPT Genetic Computer School Important If you set a foreground colour, always set a background colour, and vice versa.

DHTML AND JAVASCRIPT Genetic Computer School Colouring Alternative Rows in Data Tables......odd { background-color: lightgrey; }.even{background-color: yellow;} This is 1,1 This is 1,2 This is 1,3

DHTML AND JAVASCRIPT Genetic Computer School Background Images body { background-color: white; color: black; background-image: url(“money.jpg”); }

DHTML AND JAVASCRIPT Genetic Computer School It will appear underneath other content. Background Image You should specify an appropriate background colour. This colour will display while the image is loading, and will appear for site users who have disabled images in their browsers. If you define a graphic as the background for a page, that graphic will repeat, or tile, itself to fill up the entire browser viewport. As you scroll through the document, the image will also scroll along. This is the normal behaviour of backgrounds.

DHTML AND JAVASCRIPT Genetic Computer School Background Image Normal Behaviour As you scroll through the document, the image will also scroll along.

DHTML AND JAVASCRIPT Genetic Computer School Tiling And Scrolling Characteristics Use CSS to change both the tiling and scrolling characteristics of images.

DHTML AND JAVASCRIPT Genetic Computer School Fixed Background Image Position You can instruct the background graphic to remain in place while other objects that are placed on top of it, including text, effectively scroll over it.

DHTML AND JAVASCRIPT Genetic Computer School background-repeat: no-repeat  stops the background image from tiling.  only one instance of the image will appear in the background. repeat  is the default value repeat-x and repeat-y  repeat the image horizontally and vertically respectively.

DHTML AND JAVASCRIPT Genetic Computer School background-attachment: Controls whether or not the background image scrolls with the content. By default, it is set to scroll It can also be set to fix, background-attachment: fixed;.

DHTML AND JAVASCRIPT Genetic Computer School background-position: The background-position: (1 st value)(2 nd value)  The first value controls the horizontal position and can be left, center, or right  The second value controls the vertical position, which can be top, center, or bottom. The default value is left top. You can use percentage, instead of these keywords, for either value. Example: background-position:right bottom background-position: 80% 80%

DHTML AND JAVASCRIPT Genetic Computer School How Inheritance Works In CSS

DHTML AND JAVASCRIPT Genetic Computer School Parts Of CSS Style Rule  a selector, which defines the type(s) of HTML element(s) to which the style rule applies  a series of declarations, consisting of properties and values, those define the style

DHTML AND JAVASCRIPT Genetic Computer School Selector  Universal Selector  Element Type Selector  Class Selector  ID Selector  Pseudo-element Selector  Pseudo-class Selector  Descendant Selector  Parent-child Selector  Adjacent Selector  Attribute Selectors

DHTML AND JAVASCRIPT Genetic Computer School Universal Selector It matches every element in the document. Example: *{color: red;} All elements in the page are given a text colour of red.

DHTML AND JAVASCRIPT Genetic Computer School Element Type Selector It is the most common selector. It specifies one HTML element type with no qualifiers. In the absence of other style rules that might apply to the element type provided in the selector, this rule applies to all such elements on the page. Example: a{color: white; background-color: green; } All hyperlinks in the document will appear as white text on a green background.

DHTML AND JAVASCRIPT Genetic Computer School Class Selector To apply a style rule to a potential arbitrary group of elements in a web page  Define a class in the style sheet  Identify the HTML elements that belong to the class using the class attribute  Must precede the class name with a period.  No space is permitted between the period and the name of the class.

DHTML AND JAVASCRIPT Genetic Computer School Example:.special{font-family: Verdana, Helvetica, Arial, sans-serif;} A Special Heading This is a special paragraph. Example: p.special {font-family: Verdana, Helvetica, Arial, sans-serif;} Create the same special class, but this time it applies only to paragraph elements. Class Selector: Example

DHTML AND JAVASCRIPT Genetic Computer School ID Selector Used to target a single HTML element within a page. Must be defined in the style sheet and included explicitly in the HTML tag. Use the # symbol to identify an ID selector in the style sheet, and the id attribute to give an element an ID.  IDs must be unique within a document.  No two HTML elements in a single document should have the same id.

DHTML AND JAVASCRIPT Genetic Computer School ID Selector: Example Example: #unique {font-size: 70%;} This will be a very tiny headline.

DHTML AND JAVASCRIPT Genetic Computer School Pseudo-element And Pseudo-class They are supported by some older browsers Their implementations are not complete. They are unique among the CSS selectors in that they have no equivalent HTML tag or attribute

DHTML AND JAVASCRIPT Genetic Computer School Pseudo-element Selector Example: p:first-letter{font-face: serif; font-size:500%; float: left; color: gray;} A drop-caps effect for the first letter : The first letter in each paragraph will be five times larger than the usual type used in paragraphs. CSS specification has defined only three pseudo- elements: first-letter, first-line and first-child. To define a pseudo-element for a style rule, precede the pseudo-element name with a colon.

DHTML AND JAVASCRIPT Genetic Computer School Pseudo-class Selector A pseudo-class selector applies to a whole element, but only under certain condition. The pseudo-class selector comes into play only when the user interacts with the affected element. CSS2 defines hover, active, focus, link, visited and lang.

DHTML AND JAVASCRIPT Genetic Computer School Descendant Selector All HTML elements (except the html element) are descendants of at least one other HTML element. A descendant selector restricts the applicability of the rule of elements that are descendants of other elements. The scope of the descendant selector is determined by reading the rule from right to left. Spaces separate the element types. The descendant relationship need not be an immediate parent- child connection. Example: li em{color: green;} It will be applied to any text contained in an em, or emphasis, element only when the emphasized text is a descendant of a list item.

DHTML AND JAVASCRIPT Genetic Computer School Parent-child Selector To apply to element patterns that match a specific sequence of parent and child elements. It is a special case of the descendant selector. It must be related directly to one another in a strict inheritance sequence.

DHTML AND JAVASCRIPT Genetic Computer School Adjacent Selector Adjacency is not related to inheritance. Adjacency refers to the sequence in which elements appear in an HTML document. Adjacent elements are always siblings, but it is their placement in the document, rather than their inheritance relationship. The adjacent selector uses the +sign as its connector.

DHTML AND JAVASCRIPT Genetic Computer School Adjacent Selector: Example h1 + h2 {margin-top: 11px;} Put 11 extra pixels of space between the bottom of an h1 heading and an h2 heading that followed immediately.

DHTML AND JAVASCRIPT Genetic Computer School Attribute Selector It declares that the rule with which it is associated is applied only to elements that have a specific attribute defined, or have that attribute defined with specific value.

DHTML AND JAVASCRIPT Genetic Computer School Attribute Selector There are four levels of attribute matching: [attribute] matches if the attribute attribute is defined at all for the element(s) [attribute=”value”]matches only if attribute has a value of value [attribute~=”value”] matches only if the attribute is defined with a space- separated list of values, one of which exactly matches value. [attribute|=”value”] matches only if the attribute is defined with a hyphen- separated list of “words” and the first of these words begins with value.

DHTML AND JAVASCRIPT Genetic Computer School Measurements There are two types of measurements.  Absolute  Relative

DHTML AND JAVASCRIPT Genetic Computer School Absolute Measurement It tells the browser to render the affected content.

DHTML AND JAVASCRIPT Genetic Computer School Relative Measurement It instructs the browser to scale a value by some percentage or multiple, relative to the size of the object before the scaling take place.  Units are em and percentage.  Both the em and the percentage generate font sizes based on the inherited or default size of the font for the object to which they are applied.  ems and percentages are 1:100 in equivalent.

DHTML AND JAVASCRIPT Genetic Computer School Relative Measurement [an optional sign] [a number] [a unit of measurement] [(+ or -)] [(integer or decimal point)] [(em or %)] No spaces are permitted between the number and the unit of measurement.

DHTML AND JAVASCRIPT Genetic Computer School Layout

DHTML AND JAVASCRIPT Genetic Computer School The display property It determines how a browser displays an element, whether it treats it as a block, an inline text fragment, or something else.

DHTML AND JAVASCRIPT Genetic Computer School Six Possible Values For The Display Property  block  inline  list-item  None  table-footer-group  table header-group The default value varies from element to element.

DHTML AND JAVASCRIPT Genetic Computer School The Box Model