Cascading Style Sheets (CSS)

Similar documents
CSS.

CSS: The Basics CISC 282 September 20, 2014

CSS Cascading Style Sheets

Cascading Style Sheet. Styles as Tag Attributes. Syntax. <h1>: what font type/size is used? STYLE = SELECTOR {RULES} Attributes such as bgcolor

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

CSS مفاهیم ساختار و اصول استفاده و به کارگیری

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

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

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

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

CSS Styles Quick Reference Guide

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

Assignments (4) Assessment as per Schedule (2)

Appendix D CSS Properties and Values

Cascading Style Sheets Level 2

Unit 10 - Client Side Customisation of Web Pages. Week 5 Lesson 1 CSS - Selectors

Reading 2.2 Cascading Style Sheets

CSS: formatting webpages

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

CSS: Cascading Style Sheets

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

Cascading Style Sheets. Overview and Basic use of CSS

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

Controlling Appearance the Old Way

Cascade Stylesheets (CSS)

Adding CSS to your HTML

CSS Cascading Style Sheets

BIM222 Internet Programming

Styles, Style Sheets, the Box Model and Liquid Layout

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

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

Introduction to Web Tech and Programming

COSC 2206 Internet Tools. CSS Cascading Style Sheets

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

DAY 4. Coding External Style Sheets

ITNP43: HTML Lecture 4

HTML/XML. HTML Continued Introduction to CSS

Introduction to Cascading Style Sheets

CSS. Lecture 16 COMPSCI 111/111G SS 2018

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

CSS FOUNDATIONS IN-DEPTH. The nitty-gritty of css...

Creating and Building Websites

CSS: Cascading Style Sheets

CSS

Using Dreamweaver CS6

Web Design and Development Tutorial 03

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

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

Chapter 3 Style Sheets: CSS

CSS Lecture 16 COMPSCI 111/111G SS 2018

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

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

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

Networks and Web for Health Informatics (HINF 6220) Tutorial 8 : CSS. 8 Oct 2015

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

Parashar Technologies HTML Lecture Notes-4

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

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

8a. Cascading Style Sheet

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

CSS. Shan-Hung Wu CS, NTHU

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

Web Development & Design Foundations with HTML5

Introduction to WEB PROGRAMMING

ICT IGCSE Practical Revision Presentation Web Authoring

Tutorial 3: Working with Cascading Style Sheets

Web Site Design and Development Lecture 5

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

Web Development & Design Foundations with HTML5

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

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

Wanted! Introduction. Step 1: Styling your poster. Activity Checklist. In this project, you ll learn how to make your own poster.

LBS Polytechnic. Hey! Make With The Style Sheet Already, Bub!

Using Advanced Cascading Style Sheets

CSS 1: Introduction. Chapter 3

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 2

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

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

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

IDM 221. Web Design I. IDM 221: Web Authoring I 1

Zen Garden. CSS Zen Garden

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning

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

Lab Introduction to Cascading Style Sheets

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

Web Information System Design No.4 Put Style to Web Documents. Tatsuya Hagino

ID1354 Internet Applications

CSS3 Basics. From & CSS Visual Dictionary Learning Curve Books, LLC

Block & Inline Elements

APPLIED COMPUTING 1P01 Fluency with Technology

Using Dreamweaver. 6 Styles in Websites. 1. Linked or Imported Stylesheets. 2. Embedded Styles. 3. Inline Styles

GIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST

Chapter 4 CSS basics

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

CSS means Cascading Style Sheets. It is used to style HTML documents.

CS 350 Internet Applications I Name: Exam II (CSS) October 29, 2013

CASCADING STYLESHEETS

Media Types & Media Features

Transcription:

Cascading Style Sheets (CSS) Mendel Rosenblum 1

Driving problem behind CSS What font type and size does <h1>introduction</h1> generate? Answer: Some default from the browser (HTML tells what browser how) Early HTML - Override defaults with attributes <table border="2" bordercolor="black"> Style sheets were added to address this: Specify style to use rather than browser default Not have to code styling on every element 2

Key concept: Separate style from content Content (what to display) is in HTML files Formatting information (how to display it) is in separate style sheets (.css files). Use an element attribute named class to link (e.g. <span class="test">) Result: define style information once, use in many places Consider can you make all the text in the app slightly bigger? Or purple is our new company color. DRY principle: Don't Repeat Yourself 3

Style sheet contain one or more CSS Rules Selector Declaration Block body { font-family: Tahoma, Arial, sans-serif; color: black; background: white; margin: 8px; Property Value 4

CSS Selector Tag name Class attribute CSS h1 { color: red;.large { font-size: 16pt; HTML <h1>today s Specials</h1> <p class="large">... Tag and Class p.large {... <p class="large">... Element id #p20 { font-weight: bold; <p id="p20">... 5

CSS Pseudo Selectors hover - Apply rule when mouse is over element (e.g. tooltip) p:hover, a:hover { background-color: yellow; a:link, a:visited - Apply rule when link has been visited or not visited (link) a:visited { a:link { color: green; color: blue; 6

CSS Properties Control many style properties of an element: Coloring Size Position Visibility Many more: (e.g. p: { text-decoration: line-through; ) Also used in animation 7

Color - Properties: color & background_color Must ultimately turn into red, green, and blue intensities between 0 and 255: Predefined names: red, blue, green, white, etc. 8-bit hexadecimal numbers for red, green, blue: #ff0000 0-255 decimal intensities: rgb(255,255,0) R G B R G B Percentage intensities: rgb(80%,80%,100%) R G B Example: h1: { color: red; 8

CSS Box Model Margin Border Padding width height Element Total element width = width + left padding + right padding + left border + right border + left margin + right margin Margin & Padding Transparent 9

CSS distance units 2px pixels Absolute 1mm millimeters 2cm centimeters 0.2in inches 3pt printer point 1/72 inch Relative 2em 3rem 2 times the element s current font size 3 times the root element s current font size 10

Size Properties - Element, pad, margin, border width height padding-top padding-right padding-bottom padding-left margin-top margin-right margin-bottom margin-left - Override element defaults border-bottom-color border-bottom-style border-bottom-width border-left-color border-left-style border-left-width border-right-color border-right-style border-right-width etc. p { border: 5px solid red; 11

position property position: static; position: relative; position: fixed; position: absolute; (default) - Position in document flow Position relative to default position via top, right, bottom, and left properties Position to a fixed location on the screen via top, right, bottom, and left properties Position relative to ancestor absolute element via top, right, bottom, and left properties Fixed position (0,0) is top left corner 12

Some more common properties background-image: image for element's background background-repeat: should background image be displayed in a repeating pattern (versus once only) font, font-family, font-size, font-weight, font-style: font information for text text-align, vertical-align: Alignment: center, left, right cursor - Set the cursor when over element (e.g. help) 13

Element visibility control properties display: none; - Element is not displayed and takes no space in layout display: inline; - Element is treated as an inline element. display: block; - Element is treated as an block element. visibility: hidden; - Element is hidden but space still allocated. visibility: visible; - Element is normally displayed 14

Some other CSS issues Inheritance Some properties (e.g. font-size) are inherited from parent elements Others (border, background) are not inherited. Multiple rule matches General idea: most specific rule wins <span>text1</span> span.test { color: green <span class="test">text2</span> span { color: red 15

Adding Styles to HTML Separate style sheet (best way) <head> <link rel="stylesheet" type="text/css" href="mystyles.css" /> <style type="text/css"> body { font-family: Tahoma, Arial, sans-serif; </style> Page-specific styles </head> <body> <div style="padding:2px;... "> </body> Element-specific styles 16

body { font-family: Tahoma, Arial, sans-serif; font-size: 13px; color: black; background: white; margin: 8px; h1 { font-size: 19px; margin-top: 0px; margin-bottom: 5px; border-bottom: 1px solid black.shaded { background: #d0d0ff; <body> <h1>first Section Heading</h1> <p> Here is the first paragraph, containing text that really doesn't have any use or meaning; it just prattles on and on, with no end whatsoever, no point to make, really no purpose for existence at all. </p> <div class="shaded"> <h1>another Section Heading</h1> <p> Another paragraph. </p> </div> </body> CSS: HTML: 17

Example Output 18

CSS in the real world CSS preprocessors (e.g. less) are commonly used Add variable and functions to help in maintaining large collections of style sheets Composition is a problem It can be really hard to figure out what rule from which stylesheet is messing things up 19