IMY 110 Theme 6 Cascading Style Sheets

Similar documents
Appendix D CSS Properties and Values


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

INTERNATIONAL UNIVERSITY OF JAPAN Public Management and Policy Analysis Program Graduate School of International Relations

BIM222 Internet Programming

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

COSC 2206 Internet Tools. CSS Cascading Style Sheets

1 of 7 11/12/2009 9:29 AM

Lecture 10. CSS Properties. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Web Engineering CSS. By Assistant Prof Malik M Ali

UNIVERSITI TEKNOLOGI MALAYSIA TEST 1 SEMESTER II 2012/2013

CSS Cascading Style Sheets

CSE 154 LECTURE 3: MORE CSS

Adding CSS to your HTML

CASCADING STYLESHEETS

CSS Styles Quick Reference Guide

Introduction to Web Tech and Programming

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

Cascading Style Sheet Quick Reference

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

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

Cascading Style Sheets

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

Cascade Stylesheets (CSS)

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

CSc 337 LECTURE 3: CSS

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

CSS Cascading Style Sheets

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

8a. Cascading Style Sheet

Module 2 (VI): CSS [Part 3]

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

CSS MOCK TEST CSS MOCK TEST III

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

ID1354 Internet Applications

Cascading Style Sheets CSCI 311

CSS. Text & Font Properties. Copyright DevelopIntelligence LLC

Chapter 2 CSS for Style

Introduction to Cascading Style Sheets

Javascript Hierarchy Objects Object Properties Methods Event Handlers. onload onunload onblur onfocus

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

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

HTML/XML. HTML Continued Introduction to CSS

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

2005 WebGUI Users Conference

Cascading Style Sheets. Overview and Basic use of CSS

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

DAY 4. Coding External Style Sheets

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

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

Introduction to CSS (CSS2) Cascading Style Sheets. CSS Example. CSS Rules

Reading 2.2 Cascading Style Sheets

CSS. M hiwa ahamad aziz Raparin univercity. 1 Web Design: Lecturer ( m hiwa ahmad aziz)

Parashar Technologies HTML Lecture Notes-4

Tutorial 3: Working with Cascading Style Sheets

Three Ways to Use CSS:

CSS: Cascading Style Sheets

CSS: Lists, Tables and the Box Model

CSC 443: Web Programming

CSS.

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

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

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

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

CSS. Lecture 16 COMPSCI 111/111G SS 2018

COMS 359: Interactive Media

CMPT 165: More CSS Basics

CASCADING STYLE SHEETS (CSS) BY: RIHAM ALSMARI, PNU. Lab 4

B3: A first introduction to CSS 17/02/2006

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

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

Web Site Design and Development Lecture 6

**Method 3** By attaching a style sheet to your web page, and then placing all your styles in that new style sheet.

CSS Lecture 16 COMPSCI 111/111G SS 2018

Assignments (4) Assessment as per Schedule (2)

Introducing Cascading Style Sheets. Cascading Style Sheet Basics Creating Styles Using Styles Manipulating Styles Text Formatting with CSS

Fundamentals of Web Programming a

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

Chapter 4 CSS basics

COMP519 Web Programming Lecture 7: Cascading Style Sheets: Part 3 Handouts

CSS: The Basics CISC 282 September 20, 2014

Cascading Style Sheets (CSS)

TAG STYLE SELECTORS. div Think of this as a box that contains things, such as text or images. It can also just be a

Table of Contents Chapter 9. Working with Cascading Style Sheets ... 1

Web Site Design and Development Lecture 7. CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM

CSS for Styling CS380

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

Creating and Building Websites

APPLIED COMPUTING 1P01 Fluency with Technology

Web Design and Development Tutorial 03

CSS Tutorial Part 1: Introduction: A. Adding Style to a Web Page (3 options):

Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification

View all articles by Kevin Verdana, Tahoma, etc.) for the main body text of a site.

By Ryan Stevenson. Guidebook #3 CSS

Tutorial 4: Creating Special Effects with CSS

AN INTRODUCTION TO WEB PROGRAMMING. Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN

COMS 359: Interactive Media

Transcription:

IMY 110 Theme 6 Cascading Style Sheets

1. Cascading Style Sheets 1.1. Cascading Style Sheets Up to now we have done styling by using the style attribute. e.g. <p style = color:blue >paragraph</p> What we were actually using was a simple form of Cascading Style Sheets(CSS) called inline styling. We are going to look at three different approaches of allying CSS styling to an HTML document: Inline External Style Sheets Embedded Style Sheet (internal) 1.2. Inline Style Sheets Inline styles Sheets is the official name for the styling that we have done up to now, and is done on a tag by tag basis. The styling is placed inside the tag. <tag style = "property:value; property:value"> </tag> e.g. <p style = "color:navy; font-size:16pt; font-family:verdana"> Lorem Ipsum make it stop!</p> 1.3. Embedded Style Sheets These style sheets are also referred to as internal or nested style sheets. To use an embedded style sheet, you define a style block in the head of the document: <style type = text/css > all styling comes here </style> 1.4. External Style Sheets You can keep your style sheet in a separate file and link to it from a document or set of documents, using a <link> tag in the <head> section of the linking document, as follows:

<link rel = stylesheet type = text/css href = mystyle.css /> The text file is saved as *.css

2. CSS Structure A CSS document or a nested CSS script consists of a list of style rules. A style rule has two parts: A selector that identifies an HTML or group of s A declaration of the style properties to be applied to that selector The generic syntax for a style rule is as follows: Instead of saying: selector {property:value; property:value; } <body> </body> <p style = color:white; font-family:arial; font-style:italic > I am a paragraph yay! </p> We can say: <head> </head> <body> </p> </body> <style type = text/css > p {color:white; font-family:arial; fontstyle:italic} </style> <p> I am the same looking paragraph yay! 2.1. CSS style sheet hierarchy The ideal use of the different types of Style sheets would be to use an external stylesheet for styling a whole website. An embedded style sheet could then be used to override or extend this styling for one document. Inline styling can be used when you want to affect the formatting of only a small number of distinct s. Here it becomes apparent that there is a CSS hierarchy of importance: 1. Inline Styles 2. Embedded Style Sheets 3. External Style Sheets

2.2. CSS Comments CSS comments look different from normal HTML comments. e.g. <style type = text/css > /* This is a CSS comment! */ </style> 3. Advanced CSS Styling 3.1. Selector Classes Imagine we want to have two different looking paragraph styles that we are going to use equally often. The easiest would be to define two different types of paragraph styles, woudn't it? We can achieve this with selector classes. Example: To create a paragraph class that makes the paragraph red and aligns it to the center: p.redcenter {color:red; text-align:center} To create another paragraph class that makes the paragraph bold and arial: p.boldarial {font-weight:bold; font- family: arial} Where we now create the paragraphs: <p class = redcenter > I am a friendly red centered paragraph! </p> <p class = boldarial > I am an unfriendly bold arial paragraph, for some reason... </p> We can also combine classes: <p class = redcenter boldarial > I am a confused red centered bold <br/> arial paragraph gasp! </p>

You can also omit the tag name in the selector to define a style that will be used by all HTML s that have that class:.centeritalic { text-align:center; font-style:italic} Now different types of tags can have the same style: <h1 class = centeritalic > I m HEADING italically towards the center, get it?! </h1> <p class = centeritalic > Look at me I m centered and italic! </p> 3.2. Pseudo-Classes Pseudo-classes are used to add special effects to certain selectors. The syntax is as follows: selector:pseudo-class {property:value; } Or if used with normal classes: selector.class:pseudo-class {property:value; } Example: Anchor Styling Pseudo-class example with anchors: <style type = text/css > a:link {color:red} a:visited {color:green} a:hover {color:yellow} a:active{color:blue} </style> NB To be effective, these style rules MUST be in this order

Pseudo- class :active Purpose Adds special style to an activated :focus Adds special style to an while the has focus :hover Adds special style to an when you mouse over it :link Adds special style to an unvisited link :visited Adds special style to a visited link :first-child :lang Adds special style to an that is the first child of some other Allows the author to specify a language to use in a specified 3.3. Pseudo-Elements Pseudo-s are also used to add special effects to certain selectors. The syntax is the same as for pseudo-classes: selector:pseudo- {property:value; } Or if used with normal classes: selector.class:pseudo- {property:value; } Example: <style type = text/css > p.myclass:first-line {color:blue} p:first-letter {font-weight:bold} </style> In the <body>: <body> <p class = myclass > A lovely paragraph <br/> chopped in half! AAAH!!!

</p> </body> Pseudo- elemen t :first-letter Purpose Adds special style to the first letter of a text :first-line Adds special style to the first line of a text :before Inserts some content before an :after Inserts some content after an

4. CSS for different Elements 4.1. Background Property background backgroundposition backgroundattachment background-color A shorthand property for setting all background properties in one declaration Sets whether a background image is fixed or scrolls with the rest of the page Sets the background color of an background-color background-image background-repeat background-attachment background-position scroll fixed color-rgb color-hex color-name transparent background-image backgroundrepeat Sets an image as the background Sets the starting position of a background image Sets if/how a background image will be repeated url(url) none top left top center top right center left center center center right bottom left bottom center bottom right x y xpos ypos repeat repeat-x repeat-y no-repeat Property border border-color border-style border-width 4.2. Border A shorthand property for setting all of the properties for the four borders in one declaration Sets the color of the four borders, can have from one to four colors Sets the style of the four borders, can have from one to four styles A shorthand property for setting the width of the four borders in one declaration, can have from one to four values border-width border-style border-color color none hidden dotted dashed solid double groove ridge inset outset thin medium thick

Property height line-height max-height max-width min-height min-width width 4.3. Dimension Sets the height of an Sets the distance between lines Sets the maximum height of an Sets the maximum width of an Sets the minimum height of an Sets the minimum width of an Sets the width of an normal number none none Property font font-family font-size font-sizeadjust font-style 4.4. Font A shorthand property for setting all of the properties for a font in one declaration A prioritized list of font family names and/or generic family names for an Sets the size of a font Specifies an aspect value for an that will preserve the x- height of the first-choice font Sets the style of the font font-style font-variant fontweight font-size/line-height font-family caption icon menu message-box small-caption status-bar family-name generic-family xx-small x-small small medium large x-large xx-large smaller larger none number normal italic oblique font-variant font-weight Displays text in a small-caps font or a normal font Sets the weight of a font normal small-caps normal bold bolder lighter 100 200 300 400 500 600 700 800 900

Property list-style 4.5. Lists A shorthand property for setting all of the properties for a list in one declaration Sets an image as the list-item marker Sets where the list-item marker is placed in the list Sets the type of the list-item marker list-style-type list-style-position list-style-image none url inside outside none disc circle square decimal decimal-leading-zero lower-roman upper-roman lower-alpha upper-alpha lower-greek lower-latin upper-latin hebrew armenian georgian cjk-ideographic hiragana katakana hiragana-iroha katakana-iroha 4.6. Margins Property margin markeroffset list-styletype list-styleposition list-styleimage marginbottom margin-left margin-right margin-top A shorthand property for setting the margin properties in one declaration Sets the bottom margin of an Sets the left margin of an Sets the right margin of an Sets the top margin of an margin-top margin-right margin-bottom margin-left

4.7. Positioning Property bottom clip left overflow position right top verticalalign z-index Sets how far the bottom edge of an is above/below the bottom edge of the parent Sets the shape of an. The is clipped into this shape, and displayed Sets how far the left edge of an is to the right/left of the left edge of the parent Sets what happens if the content of an overflow its area Places an in a static, relative, absolute or fixed position Sets how far the right edge of an is to the left/right of the right edge of the parent Sets how far the top edge of an is above/below the top edge of the parent Sets the vertical alignment of an Sets the stack order of an shape visible hidden scroll static relative absolute fixed baseline sub super top text-top middle bottom text-bottom number

4.8. Table Property borderspacing bordercollapse caption-side Sets whether the table borders are collapsed into a single border or detached as in standard HTML Sets the distance that separates cell borders (only for the "separated borders" model) Sets the position of the table caption collapse separate top bottom left right empty-cells table-layout Sets whether or not to show empty cells in a table (only for the "separated borders" model) Sets the algorithm used to display the table cells, rows, and columns show hide fixed

4.9. Text Property color line-height letter-spacing text-align texttransform textdecoration text-indent text-shadow white-space word-spacing Sets the color of a text Sets the distance between lines Increase or decrease the space between characters Aligns the text in an Adds decoration to text Indents the first line of text in an Controls the letters in an Sets how white space inside an is handled Increase or decrease the space between words color normal number normal left right center justify none underline overline line-through blink none color none capitalize uppercase lowercase normal pre nowrap normal