Cascading Style Sheets CSS. Learning outcome CSS – Introduction – Motivation – Advantages – Implementation – Classes & Ids – and – General Model – Validation.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
Advertisements

Cascading Style Sheets
1 © Netskills Quality Internet Training, University of Newcastle Introducing Cascading Style Sheets © Netskills, Quality Internet.
Basic Principles for Web Design Source:
CSS-Formatting Review Cascading Style Sheets addstyle to your HTML web pages.
Intro To Cascading Style Sheets By Mario Yannakakis.
CSS Cascading Style Sheets. What is CSS? CSS stands for Cascading Style Sheets (the page—or sheet—helps you create a style that will cascade across all.
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
Cascading Style Sheets: Basics I450 Technology Seminar Copyright 2003, Matt Hottell.
Cascading Style Sheets
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.
Introduction to CSS.
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.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
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.
Building a Website: Cascading Style Sheets (CSS) Fall 2013.
CSS(Cascading Style Sheets )
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
“Cascading Style Sheets” for styling WWW information DSC340 Mike Pangburn.
กระบวนวิชา 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.
4.01 Cascading Style Sheets
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.
 Missing (or duplicate) semicolons can make the browser completely ignore the style rule.  You may add extra spaces between the properties/values to.
STYLING THE WEBSITE - EXTERNAL CSS BY JORGE MARTINEZ.
Cascading Style Sheets (Lecture 2) Topics: CSS o Introduction o Motivation o Advantages o Implementation o Classes & IDs o and o General Model o Validation.
The Characteristics of CSS
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
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.
CSS Basic (cascading style sheets)
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Essentials of HTML Class 4 Instructor: Jeanne Hart
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
DIV, Span, CSS.
3. Cascading Style Sheets (CSS) M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer.
Introduction to CSS. What is CSS? CSS ("Cascading Style Sheets") determines how the elements in our XHTML documents are displayed and formatted. By using.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
Microsoft Expression Web 3 – Illustrated Unit D: Structuring and Styling Text.
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.
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…
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.
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
Introduction to CSS.
Madam Hazwani binti Rahmat
Introduction to Web programming
Intro to CSS CS 1150 Fall 2016.
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascading Style Sheets - Building a stylesheet
Introduction to CSS.
Intro to CSS CS 1150 Spring 2017.
CIS 3.5, Spring 2010 Lecture I.2 Topics: CSS Introduction Motivation
Introduction to Cascading Style Sheets (CSS)
What are Cascading Stylesheets (CSS)?
Cascading Style Sheets™ (CSS)
Training & Development
Introduction to CSS.
Cascading Style Sheets - Building a stylesheet
Cascading Style Sheets III B. Com (Paper - VI) & III B
Introduction to Cascading Style Sheets (CSS)
Presentation transcript:

Cascading Style Sheets CSS

Learning outcome CSS – Introduction – Motivation – Advantages – Implementation – Classes & Ids – and – General Model – Validation

CSS Introduction HTML was originally designed as a simple way of presenting information, with the aesthetics less important than the content. Of course as the web grew, presentation become much more important. New tags were created to allow greater presentation freedom ( ). HTML coders quickly noticed that they were retyping the same old tags over and over leading to huge HTML files and above all, time consumption and frustration. Imagine you've just designed a two hundred page web site for a client, who at the last minute decides the font is a little two small or the typeface should be serif instead of sans-serif

Motivation In 1996 (and 1998) CSS (Cascading StyleSheets) became a formal recommendation of the W3C. Stylesheets act as partners to HTML/XHTML documents; taking care of all layout, fonts, colors and the overall look of a page/site. With CSS the idea is to leave most of the formatting out of your HTML/XHTML files and use only nice structural elements (like headings, paragraphs and links). Thus separating structure and presentation. If you decide to change the look of a site, you modify the CSS file (style sheet) and all the HTML/XHTML pages reading from that file will display differently. This makes maintenance of your design much easier.

A Simple Table Classic HTML <font face="arial" size="2" color="red"> this is line 1 <font face="arial" size="2" color="red"> this is line 2 <font face="arial" size="2" color="red"> this is line 3 With CSS (assuming "subtext" is defined) this is line 1 this is line 2 this is line 3

Advantages of CSS 1. Makes web site maintenance easier – Fewer lines to change. – Fewer pages to upload. 2.Improves page load time for a site – Style sheet is downloaded once and cached. 3.Insures page consistency within a site 1. Every page that uses your style sheet is derived from an identical style 4.Also helps improve accessibility – People can define own style sheets to override default settings (poor vision, colorblind, etc). – Mobile devices can have customized sheets. 5.There are dozens of extra formatting options and possibilities available through stylesheet commands that are not possible through normal HTML/XHTML.

Implementation CSS files are termed cascading stylesheets for two reasons: – one stylesheet can cascade, or have influence over, multiple pages. – Similarly, many CSS files can define a single page. There are 3 ways to implement CSS into your site: – Use one CSS file for all your pages. (Best Way!) – Integrate CSS commands into the head of your documents. – Use the style attribute to put CSS code directly into an element. CSS allows you to use all three of these methods together, inheriting and overriding values as you go.

One Stylesheet (to rule them all) You write just one.css file and have all pages reference it. Example: mystyle.css Syntax in CSS is DIFFERENT than in XTHML: – selector {property: value; property: value; property: value; } Examples: – body {background: blue; color: white; } – /* Previously we set the body element this way: */ – /* */ h1 {font-family: Verdana, sans-serif; color: red; font-size: 20px; } p, div, h2 {color: #00DDFF; width: 80%; } /* modifies 3 tags */

Syntax Rules 1.The selector is usually the name of a tag, without its surrounding angle-brackets. – div, span, h1 etc. 2.The braces are {curly}, not [square] or (round) After the property name there is a colon, and between each individual part there is a semicolon. Each of these pairs of properties and values is a declaration. – You can put each separate declaration on a different line to make it easier to read.

Attaching your StyleSheet In order for your XHTML pages to use a CSS, youll need to show them where the css file is. Put this line of code into the head part of any documents you want to read this file: This could be a new tag to you rel stands for the files RELationship, and type shows that its a text file acting as a CSS stylesheet You can link multiple stylesheets to a page if you want,. – (one file for your fonts, another for margins and spacing etc.)

Individual Style blocks If, a number of pages need some particular styling and you need to override the values youve defined in your main stylesheet, you can use the style blocks method. To embed style, put this into your head: p {font-weight: normal; color: gray; } h1 {color: black; } The type attribute here allows browsers to treat this code as CSS. CSS code applied in this way is not technically a stylesheet, but is called an inline style block

Using the Style Attribute If you need to modify one tag on its own you can embed style information into it using the style attribute: The style formatting will stop as soon as you close the tag its applied to, just like any other attribute, so it will be just this paragraph that will be affected. Also note that there arent any curly braces used here, but the colon/semicolon rule still applies. This method is useful for once-off formatting, and overriding previously defined properties, but you shouldnt use it very much. If you find yourself adding the same style to multiple tags, it might be worth your while promoting it to your main stylesheet, to save time and space.

Classes and IDs If you have been using a stylesheet to reformat HTML tags you might wish you could just set up certain ways of formatting HTML elements and apply them to multiple tags. You also might want to be able to define multiple types of a single tag, such as 2-3 standard paragraph types. Using classes and ids (which are roughly the same thing), you can set up these custom options, which allow you to format single tags in many different ways. They're easy to set up, fast and flexible

classes Class selectors are created by typing a dot followed by the class name. Example: You want to format lots of individual pieces of text as 12 point red Verdana, so put this line of CSS into your style:.caution {font-family: Verdana; font-size: 12pt; color: red; }.center {text-align:center;} Note the dot before the name you want to use for it. You can add classes to any element. Examples: NOTE: For classes that have multiple attributes, try to name the classes based on their function rather than their presentation

Anonymous classes <!--.fred { color: #eeebd2; background-color: #d8a29b; border: thin groove #9baab2; } --> A Simple Heading some text... some text

id ids are practically the same as classes, with one difference. Only one element can be given each id per page. The code is the same, but with hashes (#) in place of the dots. #header {width: 90%; background: white; font-size: 20px; color: purple; } stuff NOTE: – Both class and id names can contain characters a-z, A-Z, digits 0- 9, underscores and hyphens, but they cannot start with a number or dash.

Limited Classes It is possible to create "limited" classes that can only be applied to specific tags. This allows you to reuse tag names and control the application of classes without resorting to using ID's /* ******************** A Custom Unordered List ********************/ ul.cust { list-style-type:none; padding:0px; margin:0px; } li.cust { background-image:url(arrow.gif); background-repeat:no-repeat; background-position:0px 5px; padding-left:14px; }

& and are used to mark specific sections of code and are only different in that div tag acts as if a was declared before and after the start and end tag. These two tags are incredibly useful tools for identifying and selecting sections of text that you want to use a class or id on. affected text This would create your desired text, without a font tag in sight. The span tag does absolutely nothing on its own without the class attribute.

Divisions Styles can be applied to blocks of HTML code using div <!--.myclass { color: blue; background: cyan; text-decoration: underline; border: thin groove red; } --> A Simple Heading some text...

Spans spans are similar to divisions <!--.myclass { color: red; background: cyan; text-decoration: none; } --> A Simple Heading some text...

IDs <!-- #list1 { color: blue; background: cyan; text-decoration: underline; border: thin groove red; } --> First Second Third Classes specify styles for particular instances of an element IDs specify the style of a single element IDs allow the element to be identified by other elements on the page

General Model /* ***** Styles specific to this site (may be separate sheet)************/ body {background-color: teal} h1 {color:black; font-size:20pt} /* ***** Styles appropriate whenever (may be separate sheet) *************/ /* *** Color ** */ /* Color class selectors */ /* Example: <h1 class="center black"*/.black {color:black}.aqua {color:aqua}.blue {color:blue}.white {color:white}.yellow {color:yellow}

CSS Documents Can Be "Validated" You can check your.css documents to see if the are "valid" by going to the following link: If your css file violates any rules or is missing any required elements it will generate errors.

Help on CSS W3C Schools: (you can learn everything here, and they have "try it pages that let you test sections of CSS code) Other sites to look at: html

Revision Data Representation – Understand the binary system – Integer representation – Floating point – Underflow and overflow in floating point representation – ASCII Data Storage – the difference between difference types of memories and how do they work – Understand the role of cache memory – Understand how the cache memory enhances computers performance – Temporal and locality principles – Understand the role of a decoder – Address space vs the number of address lines Data processing – The component of the CPU – How these component communicate with each other – How does the CPU communicate the different memories – Advantages and disadvantages of pipelining – How to overcome pipelining hazards

Revision (Cont) Turing Machine – Understand the concept of Turing machine – Be able to write a simple turing machine programs – i.e. Program to work out the twos complement of a binary sequence or a program that mulitply a binary number by 2 or 4. ext Operating systems: – Memory management – Process management – I/O device management Computer networks – Network classes – IP addressing – subnetting XHTML – Know the difference between HTML, XML and XHTML and understand why it is advisable to code using xhtml. – Different type of DTD – Well formed vs valid xml document CSS – Difference between differente styles – Iinline style – Embedded – External CSS Next Semester we will have an extra lecture – Introduction into Assembly language (included in the exam)

2 nd coursework Check your on 22 nd of December The coursework will be available on my website and will be ed to you. You will be able to see the marks for your first assignment on the Intranet by Monday next week I will be running Math workshop next semester. So you can see at least once a week. Any problems with Data Rep course, just ask!

Fin Good luck