Style changes (contd.) When a user event happens in the context of some element, we may wish several aspect of the style to change For example, we may.

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Advertisements

Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
Cascading Style Sheets
CSS The basics { }. CSS Cascading Style Sheets - language used to – describe html appearance & formatting Style Sheet - file that describes – how html.
Layout using CSS. Using multiple classes In the head:.important{font-style:italic;}.title{color:red;} In the body: Here's a type of paragraph that is.
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.
CSS. CSS, or Cascading Styles Sheets, is a way to style HTML. Whereas the HTML is the content, the style sheet is the presentation of that document.
CHAPTER 8 ADVANCED CSS. LEARNING OBJECTIVES Assign formatting styles to a CSS class definition Use a tag’s class attribute to apply the styles defined.
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.
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.
กระบวนวิชา 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.
CSS normally control the html elements. Three Ways to Insert CSS There are three ways of inserting a style sheet: External style sheet Internal style.
XP Introducing Cascading Style Sheets With Cascading Style Sheets (CSS), you can create one or more documents that control the appearance of some or all.
Cascading Style Sheets SP.772 May 6, CSS Useful for creating one unified look for an entire web site. Helps to seperate style from content. Can.
NAMEd anchors Enabling users to jump to specific points within Web documents.
CSE CASCADING STYLE SHEETS CSS Faculty of Computer Science and Engineering.
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.
SM5312 week 6: basic CSS syntax1 An Introduction to Cascading Style Sheets Basic CSS Syntax Nick Foxall.
The.htm/.html Mystery When saving the template files in Internet Explorer, they will be named.htm by default. To be consistent with how the code was written.
Style sheets can also affect the BODY. style4.css BODY {BACKGROUND-COLOR : white} H1 {COLOR : red; FONT-SIZE : 50; FONT-FAMILY : arial} H2 {COLOR : green}
Style sheets can also affect the body. style4.css body {background-color : white} h1 {color : red; font-size : 50; font-family : arial} h2 {color : green}
NAMEd anchors Enabling users to jump to specific points within Web documents.
4.01 Cascading Style Sheets
Style changes (contd.) When a user event happens in the context of some element, we may wish several aspect of the style to change For example, we may.
Using color and fonts in HTML and XHTML Please use speaker notes for additional information!
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.
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Cascading Style Sheets by Pavlovic Nenad by. Presentation Contents  What is CSS?  Why CSS?  Types of Style Sheets  Style Sheets Syntax  Box Formatting.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
Introduction To CSS.. HTML Review What is HTML used for? Give some examples of formatting tags in HTML? HTML is the most widely used language on the Web.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Using Cascading Style Sheet As you create more web pages, you may wish to impose a consistent look for all of your web pages or for group of related pages.
Just A Few More Fun Objectives 1 Having Some Fun With Java Script 2 Using Style Sheets.
Css. Definition Cascading style sheet (CSS) Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
Cascading Style Sheets Dave Edsall IAGenWeb County Coordinator’s Conference June 30, 2007.
INTRODUCTION TO CSS. OBJECTIVES: D EFINE WHAT CSS IS. K NOW THE HISTORY OF CSS. K NOW THE REASON WHY CSS IS USED. CSS SYNTAX. CSS ID AND CLASS.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Css. Definition Cascading style sheet (CSS)  It is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
Definition CSS “Short for Cascading Style Sheets, a new feature being added to HTML that gives both Web site developers and users more control over how.
Chapter 8 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 8 Sebesta: Programming the World Wide Web.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
Creating Your Own Webpage COSC Cascading Stylesheets Think of: HTML: content of your webpage HTML has tags CSS: presentation and appearance of your.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
Advanced Web Development Instructor: Thomas Bombach.
Web Development 101 Presented by John Valance
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
A really fairly simple guide to: mobile browser-based application development (part 2, CSS) Chris Greenhalgh G54UBI / Chris Greenhalgh
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.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Modifying HTML attributes and CSS values. Learning Objectives By the end of this lecture, you should be able to: – Select based on a class (as opposed.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations Slide Set #4: CSS.
CSS Syntax. Syntax The CSS syntax is made up of three parts: a selector, a property and a value: selector {property: value}
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.
CSS Box Model. What is the Box Model? Each XHTML element appearing on our page takes up a "box" or "container" of space. Each box size is affected not.
Chapter 6 © 2003 by Addison-Wesley, Inc Introduction - Dynamic HTML is not a new markup language - A dynamic HTML document is one whose tag attributes,
CSS DHS Web Design. Location Between the & Start with – End with –
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.
Introduction to.
CSS Style Sheets: Intro
CS134 Web Design & Development
Web Design & Development
Modifying HTML attributes and CSS values
Presentation transcript:

Style changes (contd.) When a user event happens in the context of some element, we may wish several aspect of the style to change For example, we may wish to change both the font size and the color To do this, we can have several style- property settings in one event handler: ONMOUSEOVER=‘ this.style.color=“red”; this.style.fontSize=“50” ‘ ONMOUSEOUT= ‘ this.style.color=“blue”; this.style.fontSize=“20” ‘

Analysis of this: ONMOUSEOVER=‘ this.style.color=“red”; this.style.fontSize=“50” ‘ ONMOUSEOUT= ‘ this.style.color=“blue”; this.style.fontSize=“20” ‘ the overall event-handler is enclosed by apostrophes individual style settings are separated by semi-colons layout should be chosen to support human readability of the HTML specification

Style Property Names: CSS versus Javascript CSS property names can be written in upper or lower case -- although I encourage you to use lower-case, as in font-size Javascript property names do not contain hyphens and must be written in lower-case, except for capitals at word boundaries, as in fontSize, which corresponds to FONT-SIZE borderLeftWidth, which corresponds to BORDER-LEFT-WIDTH

Example Consider the next three slides –the first one shows a document before the mouse is placed over the heading –the second one shows what the document looks like when the mouse is over the heading –the third one shows what the document looks like when the mouse is moved away again

Mouse not on heading

Mouse is on heading

Mouse moves off heading again

Event-handlers to achieve this <H1 onMouseOver= 'this.style.borderStyle="solid"; this.style.borderColor="blue"; this.style.borderLeftWidth="50"; this.style.backgroundColor="black"; this.style.color="white"' onMouseOut= 'this.style.borderStyle="none"; this.style.backgroundColor="white"; this.style.color="black"' > Some Subject or Other The heading above gets...

Multiple similar event handlers: Handling these two events for one heading required a lot of typing It would be worse if we wanted to do the same thing for many headings We need some way of abbreviating event handler specification

First, a motivating example: Consider the following document with several headings Consider what happens when we move the mouse over/out with respect to these headings

Before we move mouse over anything

When mouse is over 1st heading

After mouse is moved away

When mouse is over 2nd heading

After mouse has moved out

When mouse is on 3rd heading

How this can be done economically: We must define some new “verbs” We use these new “verbs” in the heading tags

Using the new “verbs” Some Subject or Other Blah blah blah. Another Subject Blah blah blah. A Third Subject Blah blah blah.

The new “verbs” We have used two new verbs: –highlight –restore Each time one of these verbs is used, it is given one argument: the word this, which refers to the element in question

We must also define the “verbs” In JavaScript, a “verb” is called a function I think this is a terrible name, but it comes from the C language which is the parent of C++, which is the parent of Java which is one of the parents of JavaScript

Function definition General form: function ( ) { } Example: function changeStyleOf(someThing) { someThing.style.color=“red”; someThing.style.fontSize=“20” } I require to have function names which contain English verbs, as “change” is above

Formal versus Actual arguments In the function definition function changeStyleOf(someThing) { someThing.style.color=“red”; someThing.style.fontSize=“20” } the word someThing is what is called a formal argument In the event-handler onMouseOver=‘changeStyleOf(this)’ the word this is an actual argument

Formal vs. Actual args (contd.) An actual argument denotes an actual element in a document, such as a heading, or a paragraph or … Thus, in an event-handler, the word this denotes the element affected by an event A formal argument does not denote any particular element at all –it is simply used to explain the meaning of a “verb” –in the definition of changeStyleOf, the word someThing is only used to explain what should be done to an actual argument When the “verb” changeStyleOf is performed, the actions specified in the verb’s definition are applied to the actual argument

Where to put function definitions They are placed in an element called a SCRIPT element Such an element is delimited by two tags: and We can have lots of SCRIPT elements in a document However, a script element which contains function definitions should be placed in the HEAD of a HTML specification

Defining the verbs used earlier function highlight(someThing) {someThing.style.borderStyle="solid"; someThing.style.borderColor="blue"; someThing.style.borderLeftWidth="50"; someThing.style.backgroundColor="black"; someThing.style.color="white" } function restore(someThing) {someThing.style.borderStyle="none"; someThing.style.backgroundColor="white"; someThing.style.color="black" }

Overall Document Spec. (Part I) Simple Mouse Event function highlight(someThing) {someThing.style.borderStyle="solid"; someThing.style.borderColor="blue"; someThing.style.borderLeftWidth="50"; someThing.style.backgroundColor="black"; someThing.style.color="white" } function restore(someThing) {someThing.style.borderStyle="none"; someThing.style.backgroundColor="white"; someThing.style.color="black" }

Overall Document Spec. (Part II) Some Subject or Other Blah blah blah. Another Subject Blah blah blah. A Third Subject Blah blah blah.

Event-handlers can have widespread effect An event-handler attached to one element of a document can affect any part of a document In the next example, there are event- handlers attached to three headings but they all affect only the display of the first paragraph

Appearance when mouse is not on any heading

Appearance when mouse is on first heading

Appearance when mouse is on second heading

Appearance when mouse is on third heading

How this is done: Only two changes from the earlier HTML specification: –the first paragraph is given an ID, which happens to be “blah1” –all the event-handlers specify that blah1 should be highlighted or restored, as the case may be –in other words, in every event-handler, blah1 is the actual argument passed to the “verbs”

The body of this revised document: Some Subject or Other Blah blah blah. Another Subject Blah blah blah. A Third Subject Blah blah blah.

Another example: events on headings affecting their related paragraphs Some Subject or Other Blah blah blah. Another Subject Blah blah blah. A Third Subject Blah blah blah.

Mouse on first heading

Mouse on second heading

Mouse on third heading