Cascading Style Sheets for styling WWW information

Similar documents
{color:blue; font-size: 12px;}

Chapter 7 Page Layout Basics Key Concepts. Copyright 2013 Terry Ann Morris, Ed.D

Cascading Style Sheets (CSS)

CIS 467/602-01: Data Visualization

ITNP43: HTML Lecture 4

FETAC Certificate in Multimedia Production. IBaT College Swords. FETAC Certificate in Multimedia Production Web Authoring Dreamweaver 3

What is CSS? Official W3C standard for controlling presentation Style sheets rely on underlying markup structure

Dreamweaver CS4 Day 2 Creating a Website using Div Tags, CSS, and Templates

Selectors in Action LESSON 3

CSS 101. CSS CODE The code in a style sheet is made up of rules of the following types

Using Style Sheets for Consistency

Outline of CSS: Cascading Style Sheets

Web Authoring CSS. Module Descriptor

How To Create A Web Page On A Windows (For Free) With A Notepad) On A Macintosh (For A Freebie) Or Macintosh Web Browser (For Cheap) On Your Computer Or Macbook (

CSS. CSS - cascading style sheets CSS - permite separar num documento HTML o conteúdo do estilo. ADI css 1/28

Web Developer Jr - Newbie Course

Web Design Basics. Cindy Royal, Ph.D. Associate Professor Texas State University

Inspiring Creative Fun Ysbrydoledig Creadigol Hwyl. Web Design in Nvu Workbook 2

CST 150 Web Design I CSS Review - In-Class Lab

Development Perspective: DIV and CSS HTML layout. Web Design. Lesson 2. Development Perspective: DIV/CSS

CSS - Cascading Style Sheets

Garfield Public Schools Fine & Practical Arts Curriculum Web Design

Essential HTML & CSS for WordPress. Mark Raymond Luminys, Inc mraymond@luminys.com

JJY s Joomla 1.5 Template Design Tutorial:

Basic tutorial for Dreamweaver CS5

WordPress and HTML Basics

Fast track to HTML & CSS 101 (Web Design)

Web Design with CSS and CSS3. Dr. Jan Stelovsky

Interactive Data Visualization for the Web Scott Murray

USD WEB SERVICES ADOBE DREAMWEAVER CSS DEVELOPMENT

Style & Layout in the web: CSS and Bootstrap

Further web design: Cascading Style Sheets Practical workbook

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Contents. Downloading the Data Files Centering Page Elements... 6

Basics of HTML (some repetition) Cascading Style Sheets (some repetition) Web Design

HTML and CSS. Elliot Davies. April 10th,

CREATING HORIZONTAL NAVIGATION BAR USING ADOBE DREAMWEAVER CS5

Using an external style sheet with Dreamweaver (CS6)

Coding Standards for Web Development

Web Design for Print Designers WEB DESIGN FOR PRINT DESIGNERS: WEEK 6

HTML5 and CSS3 Design with CSS Page 1

Web Design and Databases WD: Class 7: HTML and CSS Part 3

Creating a Resume Webpage with

Last week we talked about creating your own tags: div tags and span tags. A div tag goes around other tags, e.g.,:

CREATING A NEWSLETTER IN ADOBE DREAMWEAVER CS5 (step-by-step directions)

Introduction to web development using XHTML and CSS. Lars Larsson. Today. Course introduction and information XHTML. CSS crash course.

Cascading Style Sheet (CSS) Tutorial Using Notepad. Step by step instructions with full color screen shots

ART 379 Web Design. HTML, XHTML & CSS: Introduction, 1-2

jquery Tutorial for Beginners: Nothing But the Goods

Introduction to Web Development

Web Design I. Spring 2009 Kevin Cole Gallaudet University

Web Design Revision. AQA AS-Level Computing COMP2. 39 minutes. 39 marks. Page 1 of 17

CHAPTER 10. When you complete this chapter, you will be able to:

HTML CSS Basic Structure. HTML Structure [Source Code] CSS Structure [Cascading Styles] DIV or ID Tags and Classes. The BOX MODEL

Designing HTML s for Use in the Advanced Editor

Slicing and Coding the Navigation Background in CSS

Web Development 1 A4 Project Description Web Architecture

Using Adobe Dreamweaver CS4 (10.0)

CST 150 Web Design and Development I Midterm Exam Study Questions Chapters 1-3

Campaign Guidelines and Best Practices

Appendix H: Cascading Style Sheets (CSS)

Web Design for Programmers. Brian Hogan NAPCS Slides and content 2008 Brian P. Hogan Do not reproduce in any form without permission

Лваполо. Customization

CSS for Page Layout. Key Concepts

Introduction to Adobe Dreamweaver CC

Microsoft Expression Web Quickstart Guide

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Cascading Style Sheets

Dreamweaver. Introduction to Editing Web Pages

Web Development I & II*

Contents. Introduction Downloading the Data Files... 2

Building a Horizontal Menu in Dreamweaver CS3 Using Spry R. Berdan

Advanced Online Media Dr. Cindy Royal Texas State University - San Marcos School of Journalism and Mass Communication

SharePoint Designer Tutorial

WEB DEVELOPMENT IA & IB (893 & 894)

HTML5 and CSS3 Part 1: Using HTML and CSS to Create a Website Layout

Responsive Web Design Creative License

Step 2 Open Kompozer and establish your site. 1. Open Kompozer from the Start Menu (at the Polytechnic) or from the downloaded program.

Responsive Web Design: Media Types/Media Queries/Fluid Images

ideally have started work on it. The WWW assignment is due on Monday 28 th October at 4pm.

Creating Web Pages with Dreamweaver CS 6 and CSS

Level 1 - Clients and Markup

Introduction to Web Technologies

KOMPOZER Web Design Software

ICE: HTML, CSS, and Validation

IT3504: Web Development Techniques (Optional)

MCH Strategic Data Best Practices Review

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

CS134 Web Site Design & Development. Quiz1

OPENTABLE GROUP SEARCH MODULE GETTING STARTED ADD RESERVATIONS TO YOUR WEBSITE

Web layout guidelines for daughter sites of Scotland s Environment

Client Side Customisation of Web Pages

EUROPEAN COMPUTER DRIVING LICENCE / INTERNATIONAL COMPUTER DRIVING LICENCE WEB EDITING

COMMONWEALTH OF PENNSYLVANIA DEPARTMENT S OF Human Services, INSURANCE, AND AGING

Web Building Blocks. Joseph Gilbert User Experience Web Developer University of Virginia Library

How to Create an HTML Page

HTML, CSS, XML, and XSL

Introduction to Web Design Curriculum Sample

Pizza SEO: Effective Web. Effective Web Audit. Effective Web Audit. Copyright Pizza SEO Ltd.

HTML TIPS FOR DESIGNING

Transcription:

Cascading Style Sheets for styling WWW information DSC340 Mike Pangburn

CSS Advantages Makes website more flexible CSS is reusable Change stylesheet to change design of many pages Example: CSS Zen garden http://www.csszengarden.com/ Easier to maintain Cleaner HTML code Separates styles from HTML tags and page content Consistent look across entire website that is easily maintained by changing styles in one place.

CSS Disadvantages Not uniformly supported by all browsers. Firefox adheres to CSS standards more than IE For this course we use Firefox

CSS: adding style CSS allows you to add style to an HTML (web page) element E.g., color, size, or positioning information There are two aspects to adding style to a web page via CSS Specifying what the style looks like Called the CSS style Declaration Naming the HTML (or XML) element to which the style applies Referred to as specifying the CSS Selector

CSS: adding style The declaration part looks a bit like HTML: { font-size: 10px; background-color: #fff; color: #222; margin: 20px; } The above CSS declaration takes an HTML element and adds a background color, a margin, and changes the element s font size/ color

CSS: adding style A question: how does the browser know which HTML element on the webpage this declaration applies to? { font-size: 10px; background-color: #fff; color: #222; margin: 20px; }

CSS: adding style Answer: we precede the declaration with the selector. For example: body { font-size: 10px; background-color: #fff; color: #222; } this tells the browser to apply the declared style to the HTML <body> element.

The most basic kind of CSS selector Simple type selectors!ex.: body{}, p{}, strong{}! Selects every instance of the corresponding HTML element These simple selectors are commonly used Wildcard selector!* { }! Selects all elements on a page Can be used in combination with other selectors

Aside: grouping selectors You can apply the same declaration to a group of selectors by listing all of the desired selector names separated by commas. Example: h1, h2, h3, h4, h5, h6 {color:#ff0000; font-family:sans-serif}!

CSS: selector flexibility The usefulness of selectors relates to how much specificity you have in selecting different parts of a web page. Simple example: your personal webpage You may not want the same font/color type style throughout the entire <body> element

CSS: selector flexibility You could use the declaration with the selector just for the HTML <p> tag p { font-size: 10px; background-color: #fff; color: #222; } this tells the browser to apply the declared style to HTML <p> tags. But, what if you want <p> blocks in the About Me section to look one way, and those within your Education section to be styled differently?

Naming HTML elements There are two naming options for an HTML element: assigning ID names and class names. When you give an HTML element a class or id name, you need to use that name when making the corresponding style declaration These two options are very similar, and the class name approach is more popular, so we focus on that. Aside: An id declaration is the same as a class declaration, except that it should only be used once per web page The syntax for id vs. class is also nearly identical, the only difference being the use of a pound sign (#) instead of the period (.) you will see in a couple slides.

Example: naming HTML elements The following HTML block gives the class name myboldandbluelook to the first <h1> tag. The name does not apply to the <p> tags nor the other <h1> tag. <html> <body> <h1 class= myboldandbluelook > Introduction </h1> <p> a paragraph <h1> Summary </h1> <p> a paragraph </body> <html>

Connecting a style declaration to a class name To connect a style declaration to a particular class name you wrote into your HTML document, you simply precede the class declaration with:.theclassname Example.myboldandbluelook! {! font-weight: bold;! color: blue;! }!! Aside: if you want this style to be used only once in the web page, then specify it as an ID style with this slight syntax change: #myboldandbluelook! {! font-weight: bold;! color: blue;! }

More on selector options Descendant (nested) selector ul li a strong{color:green;}! Syntax is similar to the example of grouping selectors but without the commas Selects all elements that correspond to the nested structure specified by the selector E.g., the above style will apply to any <strong> HTML tag that lies within an <a> tag that lies within an <li> tag that lies within a <ul> tag Very (!!!) specific nice!

Aside: styling hyperlinks You can style links to respond dynamically. The associated style selectors are called the hyperlink (or anchor ) pseudo-class selectors: :link, :visited, :hover, :active { } Example: a:link {color:#ff0000;} /* color to apply to link before it s visited */ a:visited {color:#00ff00;} /* color to apply to link before it s visited*/ a:hover {color:#ff00ff;} /* color to apply to link while mouse pointer is over it*/ a:active {color:#0000ff;} /* color to apply while left mouse button is held down on link */ Note: a:hover MUST be listed after a:link and a:visited! Note: a:active MUST be listed after a:hover!

CSS: what does cascading mean? Cascading means a more-specific selector beats out a less-specific selector. For example, with styles....red { color: red; }! body { color: black; }! What will this HTML look like? <body>! <p>i am black</p>! <p class="red">i am red</p>! </body>!

CSS: the cascade What if there is a tie regarding how specific the selectors are? p{font-weight:bold;} p{font-weight:normal;} p{color:green;} <p>this will be green text with a normal font weight</p> When there is a tie, the tied selector that is most immediately preceding the HTML element wins (in this case, the second p selector) In other words, in a tie, the last-defined selector wins

How/where do we add the style declarations to our HTML files? Two good approaches for named (class or id) styles: Internal stylesheet Put the style declarations in the <head> of HTML text file External stylesheet Put the style declarations in a separate text file and then import that text file into your HTML file

How/where do we add the style declarations to our HTML files? Third approach when you don t want to bother naming/reusing a style: Inline style Simply put the style declaration within the HTML tag where it s used Example <p style= font-size: 14px; >Text</p> Note: instead of using an inline (i.e., embedded in HTML) style, we could use our HTML tags <p> <font size= 14px >Text</font> </p>

Internal Style sheet example <head> <style type= text/css > CSS Code Here </style> </head>

Preferred method: External Style Sheet You create a separate style document (example: style.css). Insert it into your html head tag <head> <link rel= stylesheet href=http://yoursite.com/style.css type= text/css > </head> Aside: the above link tag works for Importing a stylesheet, and there is also an equivalent <@import> tag

Recap: 3 places to define styles Inline apply style attribute to a single tag Takes a lot of work to maintain across a website Internal, ( embedded, global ) stylesheet defined in the <head> tag of a page External style sheet (a.css text file) same functionality as Internal

Resources Nice description for beginners: http://www.cssbasics.com/introduction-tocss/ Nice tutorial for beginners: http://www.w3.org/style/examples/011/ firstcss