CSS: The Basics CISC 282 September 20, 2014

Similar documents
8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2)

Appendix D CSS Properties and Values

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

Reading 2.2 Cascading Style Sheets

Web Development & Design Foundations with HTML5

Web Development & Design Foundations with HTML5

CSS for Styling CS380

CSS Selectors. element selectors. .class selectors. #id selectors

COSC 2206 Internet Tools. CSS Cascading Style Sheets

CSS. Lecture 16 COMPSCI 111/111G SS 2018

Review Question 1. Which tag is used to create a link to another page? 1. <p> 2. <li> 3. <a> 4. <em>

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

CSS Lecture 16 COMPSCI 111/111G SS 2018

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

Cascading Style Sheets (CSS)

CSS Cascading Style Sheets

ITNP43: HTML Lecture 4

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations

HTML/XML. HTML Continued Introduction to CSS

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

CSS: Selectors and Best Practices

- The CSS1 specification was developed in CSSs provide the means to control and change presentation of HTML documents

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

CSc 337 LECTURE 3: CSS

Controlling Appearance the Old Way

Introduction to Web Tech and Programming

CSC 443: Web Programming

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

Fundamentals of Web Programming a

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

Tutorial 3: Working with Cascading Style Sheets

CSS.

Cascade Stylesheets (CSS)

Web Site Design and Development Lecture 6

Chapter 3 Style Sheets: CSS

Session 4. Style Sheets (CSS) Reading & References. A reference containing tables of CSS properties

Creating A Website - Part 1: Web Design principles, HTML & CSS. CSS Color Values. Hexadecimal Colors. RGB Color

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

Assignments (4) Assessment as per Schedule (2)

CSS: Cascading Style Sheets

ACSC 231 Internet Technologies

Zen Garden. CSS Zen Garden

The Benefits of CSS. Less work: Change look of the whole site with one edit

2. Write style rules for how you d like certain elements to look.

CSS Styles Quick Reference Guide

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Cascading Style Sheets Level 2

EECS1012. Net-centric Introduction to Computing. Lecture 3: CSS for Styling

Adding CSS to your HTML

The building block of a CSS stylesheet. A rule consists of a selector and a declaration block (one or more declarations).

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

Chapter 4 CSS basics

DAY 4. Coding External Style Sheets

Three Ways to Use CSS:

CSS Cascading Style Sheets

CSE 154 LECTURE 3: MORE CSS

Admin. Midterm 1 on. Oct. 13 th (2 weeks from today) Coursework:

Web Design and Development Tutorial 03

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

ID1354 Internet Applications

CSS: Formatting Text. CSS for text processing: font-family. Robert A. Fulkerson

Chapter 12: FORMATTING TEXT

CHAPTER 4 CASCADING STYLE SHEETS BASICS KEY CONCEPTS

CSCB20 Week 7. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

CSS: Cascading Style Sheets

Cascading Style Sheets. Overview and Basic use of CSS

CSC309 Programming on the Web week 3: css, rwd

Text and Layout. Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 11. This presentation 2004, MacAvon Media Productions

escuela técnica superior de ingeniería informática

Creating and Building Websites

CITS3403 Agile Web Development 2019 Semester 1

CSS: formatting webpages

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube {

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

Lab Introduction to Cascading Style Sheets

INFORMATICA GENERALE 2014/2015 LINGUAGGI DI MARKUP CSS

Anatomy of a Style. Cascaded Style Sheets - CSS. CSS Presentation Description Language. Measurement Specification

In the early days of the Web, designers just had the original 91 HTML tags to work with.

Introduction to CSS. Fijihosting.com Introduction to CSS page 1. What are style sheets? Lovely! How do I use them?

8a. Cascading Style Sheet

Web Site Design and Development Lecture 5

To link to an external stylesheet, the link element is placed within the head of the html page:

Faculty of Engineering Department of Computer Engineering. CSS Tutorial. Eng. Ahmed J. Alajrami

Salvedicta. - Hans Selye CSC 210

Styles, Style Sheets, the Box Model and Liquid Layout

Introduction to Cascading Style Sheets

ICT IGCSE Practical Revision Presentation Web Authoring

Web Design and Development ACS-1809

CASCADING STYLESHEETS

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

Web Development & Design Foundations with HTML5, 8 th Edition Instructor Materials Chapter 3 Test Bank

Comp-206 : Introduction to Software Systems Lecture 23. Alexandre Denault Computer Science McGill University Fall 2006

Using CSS in Web Site Design

CSS 1: Introduction. Chapter 3

COMS 359: Interactive Media

Transcription:

CSS: The Basics CISC 282 September 20, 2014 Style Sheets System for defining a document's style Used in many contexts Desktop publishing Markup languages Cascading Style Sheets (CSS) Style sheets for HTML 2

Background CSS1 Recommended by W3C in 1996 CSS2 Developed in 1998 Included many new features, but not all were supported CSS2.1 Developed in response to issues with CSS2 Browser support is excellent CSS3 Series of modules at various recommendation levels by the W3C since 2011 Browser support continues to improve 3 Why Use CSS? Flexible Apply style in one, many, or all cases Different tags, elements, contexts Centralized Change one style sheet change all usages Powerful Many features for text and layout 4

Style Sheet Levels Inline Lowest level Takes precedence over all other specifications <p style="color: red"> A paragraph </p> 5 Style Sheet Levels Document Mid-level Has precedence for the given document, but not over inline Selector Property <head> <style> p { color: red; </style> </head> Rule Value 6

Style Sheet Levels External Highest level Does not take precedence over inline or document styles Rules are defined in another file This is the standard p { color: red; Rule 7 External Style Sheets Rules defined in separate text file Include in an (X)HTML document header <link rel="stylesheet" type="text/css" href="path"> Relationship to Document MIME Type Path to File Include in an HTML5 document header <link rel="stylesheet" href="path"> Relationship to Document Path to File 8

Why Use External? Can be applied to multiple pages Can be validated Naturally separates content (HTML) from style (CSS) Keeps everything centralized 9 CSS Rules Used to define styles for the document Selector: what to apply the style to Property: what you want changed Value: how you want it changed /* comments */ selector { property1: value1; property2: value2;... 10

Type Selectors Use HTML element names p { color: red; h1, h2 { color: blue; Applied to all instances of the element(s) 11 Class Selectors Use a class name preceded by a period.warningtext { color: yellow; Applied to all elements where the class name is specified as an (or one of many) attribute(s) <p class="warningtext"> <h1 class="warningtext rightalign"> 12

ID Selectors Use an ID preceded by # #links { color: blue; Applied to the single element with the specified ID <a id="links" href="..."> 13 Contextual Selectors Two or more selectors separated by whitespace Represents a series of nested elements outer inner p em { color: purple; #links ul.external { color: orange; Also known as descendant selectors Applied to all elements in the given context Order is important! 14

Other Selectors Universal selector Applied to all elements in the document * { color: gray; Child selector Applied to inner elements nested immediately within outer element And more!.listhightlight > li { color: fuchsia; 15 Combining Selectors You can combine type, class and/or ID selectors together to specify a particular element p#problemdescription.errortext.highcontrast { color: red; background color: white; <p id="problemdescription" class="errortext highcontrast"> Rule not applied; incorrect tag <h1 id="problemdescription" class="errortext highcontrast"> Rule applied 16

Properties Over 60 different properties in CSS 2.1 Fonts and text alignment Lists Colours Backgrounds Margins and borders Each property has permitted value types Numbers Percentages Keywords A combination thereof 17 Specifying Colours Named predefined colour W3C has a list for CSS 2.1 RGB value Specifies values from 0-255 for red, green and blue e.g., rgb(255, 0, 0) Hexadecimal value Specifies values from 00 FF for red, green and blue e.g., #8000FF A simple, basic colour scheme works well 18

Colour Properties color Specifies foreground (usually text) colour Value: predefined name, RGB or hexadecimal background color Sets the background colour Value: predefined name, RGB or hexadecimal 19 Font font family Declares the font to be used Value: list of "font name"s and generic names List is separated by commas and evaluated from left to right font family: "Verdana", "Arial", sans serif; Generic names represent predefined families serif, sans-serif, monospace, cursive, fantasy Some named fonts may not be available Not everyone has them installed on their machine A font service might be unavailable End with a generic name as a default 20

Font font size Specifies the size of the characters Value: unit value, percentage or named Unit values Points (pt), pixels (px) or m-sizes (em or rem) em is relative to parent element s font size rem is relative to html element s font size Percentage Relative to parent element s font size Absolutely-named sizes xx small, x small,..., xx large Relatively-named sizes smaller, larger 21 Font font style Denotes text as normal or italics Value: normal or italic font weight Denotes text as normal or bold Value: normal or bold text align Specifies text alignment Value: left, center, right or justify 22

Font text decoration Specifies "decor" for characters Values: underline, overline, line through or none line height Sets the height of each line (not character) Typical value: number relative to font size (e.g., 1.5) Other values: unit value (pt, px, em or rem) or percentage 23