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

Similar documents
Chapter 3 Style Sheets: CSS

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

Assignments (4) Assessment as per Schedule (2)

CSS: The Basics CISC 282 September 20, 2014

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

Appendix D CSS Properties and Values

CSS. Lecture 16 COMPSCI 111/111G SS 2018

Controlling Appearance the Old Way

CSS Lecture 16 COMPSCI 111/111G SS 2018

CSS.

Styles, Style Sheets, the Box Model and Liquid Layout

Methods for configuring Cascading Style Sheets. Applying style to element name selectors. Style Rule Basics. CMPT 165: Cascading Style Sheets

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

Reading 2.2 Cascading Style Sheets

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

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

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

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

Cascading Style Sheets (CSS)

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

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

CSS Cascading Style Sheets

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

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

ID1354 Internet Applications

CSS Cascading Style Sheets

Web Site Design and Development Lecture 5

BIM222 Internet Programming

What is CSS? NAME: INSERT OPENING GRAPHIC HERE:

Cascading style sheets

Web Design and Development Tutorial 03

Cascading Style Sheets Level 2

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

CSS for Styling CS380

Introduction to Cascading Style Sheet (CSS)

Downloads: Google Chrome Browser (Free) - Adobe Brackets (Free) -

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

Navigation. Websites need a formalized system of links to allow users to navigate the site

Comm 244 Week 3. Navigation. Navigation. Websites need a formalized system of links to allow users to navigate the site

CREATING A WEBSITE USING CSS. Mrs. Procopio CTEC6 MYP1

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

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

Cascade Stylesheets (CSS)

ITNP43: HTML Lecture 4

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

Web Engineering CSS. By Assistant Prof Malik M Ali

INFORMATICA GENERALE 2014/2015 LINGUAGGI DI MARKUP CSS

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

CS134 Web Site Design & Development. Quiz1

Lecture B3 Style : Algorithmic Thinking. Computing and Art : Nature, Power, and Limits CC 3.12: Fall 2007

Creating and Building Websites

Shane Gellerman 10/17/11 LIS488 Assignment 3

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

Lab Introduction to Cascading Style Sheets

Three Ways to Use CSS:

HTML and CSS: An Introduction

Cascading style sheets, HTML, DOM and Javascript

Using Dreamweaver CS6

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

Introduction to using HTML to design webpages

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

Introduction to Cascading Style Sheets

Block & Inline Elements

Introduction to HTML & CSS. Instructor: Beck Johnson Week 2

Cascading Style Sheet Quick Reference

HTML/XML. HTML Continued Introduction to CSS

CSC 443: Web Programming

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

ICT IGCSE Practical Revision Presentation Web Authoring

Outline. Link HTML With Style Sheets &6&7XWRULDO &66 ;+70/ (GZDUG;LD

Scripting for Multimedia LECTURE 5: INTRODUCING CSS3

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

3. Each of these mark examples contains an error. a. <input name= country value= Your country here. /> b. <checkbox name= color value= teal />

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

Introduction to WEB PROGRAMMING

The internet is a worldwide collection of networks that link millions of computers. These links allow the computers to share and send data.

MEXICO 2015, ilab XALAPA

What is the Box Model?

CSS: Cascading Style Sheets

HTMLnotesS15.notebook. January 25, 2015

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

CSS. Location, Inheritance & the Cascade. Copyright DevelopIntelligence LLC

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

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

ICT IGCSE Practical Revision Presentation Web Authoring

Tutorial 3: Working with Cascading Style Sheets

APPLIED COMPUTING 1P01 Fluency with Technology

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

Web Development & Design Foundations with HTML5

CSS worksheet. JMC 105 Drake University

CSS: formatting webpages

Basic Web Pages with XHTML (and a bit of CSS) CSE 190 M (Web Programming), Spring 2008 University of Washington Reading: Chapter 1, sections

Web Development & Design Foundations with HTML5

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

Positioning in CSS: There are 5 different ways we can set our position:

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

CMPT 165 Unit 3 CSS Part 1. Sept. 24 th, 2015

Transcription:

INTRO TO CSS

RECAP HTML WHAT IS CSS ADDING CSS TO YOUR HTML DOCUMENT CSS IN THE DIRECTORY TREE CSS RULES A FEW CSS VALUES (colour, size and the box model) CSS SELECTORS SPECIFICITY

WEEK 1 HTML In Week 1 we were introduced to a basic definition of a website, followed by an introduction to HTML. We defined HTML as code that displays text on electronic devices, and then went on to examine the elements and tags that make up a basic HTML page. We also saw that naked HTML elements displayed in the browser didn t look good at all. This week we will be introduced CSS, and begin to explore how it is used to add some visual style to our HTML pages. We will also run through a few important ideas that will help you understand how css is applied.

What is CSS? CSS stands for Cascading Style Sheets. It allows you to attach style rules to your HTML elements such as <body>, <h1>, <p> or <a>. These rules define the presentational aspects of your web pages in other words, how your page looks. One of important roles of CSS is the separation of content from presentation. The major advantages of separating content from presentation are; increased accessibility, improved site performance, and most importantly decreased production and maintenance work.

Adding CSS There are three ways of inserting styles into your HTML document; Inline CSS Internal CSS External CSS

INLINE CSS Inline CSS is added directly to every HTML element on a page, this of course becomes very inefficient. <body style= width:1000px > <h1 style= font-size: 30px >TEST PAGE</h1> <p style= font-size: 14px >This is a paragraph</p> </body>

INTERNAL CSS Internal CSS is added to the head section of your HTML page - also inefficient, but a little better than inline style rules: <head> <style> body{ width:100px;} h1 { font-size:30px;} p { font-size: 14px;} </style> </head>

EXTERNAL CSS External CSS is the best and most efficient way to apply styles to a website/page, as it completely separates the presentation information into a separate document. This of course means you can use the same CSS file for multiple webpages. Pages using external css files link to the stylesheet with the <link> tag found inside the head section of a HTML page. <head> <link rel="stylesheet" type="text/css href= css/stylesheet.css"> </head>

CSS RULES External CSS files are made up of a collection of CSS rules. A CSS rule has two main parts: a selector followed by one or more declarations. Eg A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets

CSS RULES As we learnt last week with HTML, indenting your css will make your code far more readable. h1 { colour: blue; font-size:12px; }

EXERCISE 1

CSS VALUES - COLOR When defining css values there are many different options that can be used, and attempting to remember them can seem overwhelming! When defining the color of an element there are 16 color value keywords that can be used: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white and yellow. You also have hexadecimal colours ranging from #000000 (black) to #ffffff (white). In addition, RGB values may be expressed in percentage and decimal forms. Using programs like Photoshop enables you to select your color values from your designs very easily. h1 { color: black; } h1 { color: #000000;} h1 { color: rgb(0,0,0);}

CSS VALUES - SIZE When declaring size values, you will primarily use percent (%), ems (em) or pixels (px) to express any size values. Pixels are an absolute value, therefore, if you declare something as 300px, it will be exactly 300px. Percent and ems are relative values, meaning that the browser calculates the size of the element relative to its parent s size value. For example, if the font size is declared to be 20px in the body, and then 80% for paragraphs, paragraph fonts will display at 16 pixels. 1em is equal to the current font size. 2em means 2 times the size of the parent font. h1 {font-size: 20px;} h1 {font-size: 200%;} h1 {font-size: 2em;}

The CSS Box Model Another handy concept to grasp when working with CSS is that any element in your HTML file may be thought of as a box. Each box has a number of properties that you can manipulate with your style sheet, such as margin, border and padding properties etc.

EXERCISE 2

CSS SELECTORS A CSS selector is the part of the style rule that tells the browser which element in your HTML mark-up your styles should be applied to. CSS uses several different types of selectors to specifically target elements within a HTML document. These include type selectors, class selectors, id selectors and descendant selectors.

TYPE SELECTORS The type selector is the most basic form of css selector. It simply uses an elements name to apply style declarations to all instances of the the selected element. eg p { } margin: 1em;

CLASS SELECTORS (.) The Class Selector uses the class attribute added to any element in your HTML to target that instance of the element. In its simplest form, the mark-up would look like this. Class selectors can be applied to multiple elements within your HTML <p class= main-paragraph >This is the main paragraph</p>.main-paragraph { } color: red;

ID SELECTORS (#) The ID selector is very similar to the class selector, with an important distinction; the rule can only be applied once as each id attribute in an HTML document must be unique. <div id= contact"> This is some contact information </div> #contact { color: blue; }

DESENDANT SELECTORS The descendant selector s subject is the descendant of an element. In the following example, the selector targets the unordered list within the element with an id attribute value of navigation. <div id= navigation"> <ul> <li>home</li> <li>about</li> <li>contact</li> </ul> </div> #navigation ul { margin: 0; padding: 0; background-color: #069; color: #fff; }

EXERCISE 3

CSS SPECIFICITY Specificity determines, which CSS rule is applied by the browsers. Specificity is usually the reason why your CSS-rules don t apply to some elements, although you think they should. Every selector has its place in the specificity hierarchy. If two selectors apply to the same element, the one with higher specificity wins. When selectors have an equal specificity value, the latest rule is the one that counts. When selectors have an unequal specificity value, the more specific rule is the one that counts. The last rule defined overrides any previous, conflicting rules. The embedded style sheet has a greater specificity than other rules. ID selectors have a higher specificity than attribute selectors. A class selector beats any number of element selectors.