cs002 Lab 5 An Introduction to CSS

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

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

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

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

ITNP43: HTML Lecture 4

CIS 467/602-01: Data Visualization

JJY s Joomla 1.5 Template Design Tutorial:

Web Design with CSS and CSS3. Dr. Jan Stelovsky

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

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

Creating Web Pages with Dreamweaver CS 6 and CSS

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

HTML and CSS. Elliot Davies. April 10th,

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

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

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

Creating a Resume Webpage with

Using Style Sheets for Consistency

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 (

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

Cascading Style Sheets (CSS)

Introduction to Adobe Dreamweaver CC

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

ICE: HTML, CSS, and Validation

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

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

Contents. Introduction Downloading the Data Files... 2

Appendix H: Cascading Style Sheets (CSS)

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

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

HTML5 and CSS3 Design with CSS Page 1

Microsoft Expression Web Quickstart Guide

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

Website Development. 2 Text. 2.1 Fonts. Terry Marris September We see how to format text and separate structure from content.

Programming exercises (Assignments)

Interactive Data Visualization for the Web Scott Murray

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

Basic tutorial for Dreamweaver CS5

Mobile Web Site Style Guide

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

HTML, CSS, XML, and XSL

HTML TIPS FOR DESIGNING

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

ITP 101 Project 3 - Dreamweaver

Outline of CSS: Cascading Style Sheets

Advanced Drupal Features and Techniques

Recreate your Newsletter Content and Layout within Informz (Workshop) Monica Capogna and Dan Reade. Exercise: Creating two types of Story Layouts

MCH Strategic Data Best Practices Review

Selectors in Action LESSON 3

Kentico CMS, 2011 Kentico Software. Contents. Mobile Development using Kentico CMS 6 2 Exploring the Mobile Environment 1

How to Properly Compose HTML Code : 1

Cascading Style Sheets

Using an external style sheet with Dreamweaver (CS6)

GUIDE TO CODE KILLER RESPONSIVE S

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

Advanced Web Design. Zac Van Note.

Create Webpages using HTML and CSS

Creating A Webpage Using HTML & CSS

Web Design and Development ACS Chapter 9. Page Structure

Learning Web Design. Third Edition. A Beginner's Guide to (X)HTML, Style Sheets, and Web Graphics. Jennifer Niederst Robbins

GUIDE: How to fill out the Excel spreadsheet Introduction There is a total of 31 fields Purpose of this guide General Notes: Very important:

Simply download Beepip from and run the file when it arrives at your computer.

Web Design I. Spring 2009 Kevin Cole Gallaudet University

Garfield Public Schools Fine & Practical Arts Curriculum Web Design

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

Scoop Hosted Websites. USER MANUAL PART 4: Advanced Features. Phone: scoop@scoopdigital.com.au Website: scoopdigital.com.

CSS for Page Layout. Key Concepts

Digital Marketing EasyEditor Guide Dynamic

LEAGUE OF WOMEN VOTERS NAME & LOGO GUIDELINES

We automatically generate the HTML for this as seen below. Provide the above components for the teaser.txt file.

CS134 Web Site Design & Development. Quiz1

Further web design: Cascading Style Sheets Practical workbook

Learnem.com. Web Development Course Series. Quickly Learn. Web Design Using HTML. By: Siamak Sarmady

Creator Coding Guidelines Toolbox

Web layout guidelines for daughter sites of Scotland s Environment

Web Development I & II*

But have you ever wondered how to create your own website?

Website Development Komodo Editor and HTML Intro

How to code, test, and validate a web page

Advanced Editor User s Guide

A Twine Cheat Sheet (a start, at least)

Google Sites: Site Creation and Home Page Design

Create Your own Company s Design Theme

How to craft a modern, mobile-optimized HTML template. Jason Samuels, NCFR IT Manager DrupalCamp Twin Cities May 2012

White Paper Using PHP Site Assistant to create sites for mobile devices

Developers Guide. Designs and Layouts HOW TO IMPLEMENT WEBSITE DESIGNS IN DYNAMICWEB. Version: English

Dreamweaver Domain 2: Planning Site Design and Page Layout

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

AEGEE Podio Guidelines

How to Create an HTML Page

Transcription:

Assigned: October 31, 2016 Due: November 11, 2016 Introduction Last week, we started working with HTML, a markup language for describing how content on web pages should be laid out. You may have noticed that the pages you created looked like they belong to professors ( like this one ). This week, we re going to continue working with HTML, but this time we re going to do it with style. CSS (Cascading Style Sheets) is the modern way to style a web page. If you want to color some text, change the position of a link, or even change the cursor when you hover over an image, you use CSS. Back in the 90's, people used HTML tags to change the font and color of a web page, but this resulted in a mess where the structure and information of a web page was mixed in with how it should look. The W3C (World Wide Web Consortium), the standards body that controls HTML and other web related standards, created CSS as a solution to more easily manage the look and feel of websites. Lab Goals Continue working with HTML to create web pages with interesting content Add CSS to web pages to make them more visually appealing Experiment with different CSS selectors and properties Practice reading and understanding pre-existing code. Lab Assignment Important Note Before Getting Started: You cannot copy-and-paste the example code we provided, because quotes and other special characters will not copy-and-paste correctly. For practice and to avoid copy-and-paste errors, you should always type out your own code and do not just copy-and-paste from this document. An important concept within CSS is the selector. Selectors are used to determine what part of your web page you want to affect. While there are many different types of selectors, these three are the most common and most important to know: Tag name: You can select all tags of a certain type in order to affect them and their descendants. To select everything enclosed by a tag <div> in the HTML, you just write div in the CSS. Tag ID: You can select a tag with a specific ID (IDs must be unique). To select a

tag with the HTML ID my_id ( id= my_id ), write #my_id in your CSS file. Class: You can select all tags in your HTML file that are members of a class ( class= my_class ) by writing.my_class (that's a period before my ) in your CSS file. You can then set the properties of parts of your page as follows: :selector: { property-name : value; The placeholder :selector: shows where you can write one of the above-mentioned selectors. property-name is the property you want to set for the elements that you select. value is what you are setting this property to. Here are some common properties you might want to use: Property name Description Accepted Values color Sets the text color Color names (red, green, teal), RGB values (rgb(x, y, z), or hexadecimal values (#ffffff, #FFCC33) text-align Aligns text left, right, center, justify font-size Sets the size of the text Values in px or em (12px, 2em) font-weight Sets the weight of text normal, bold, bolder text-decoration font-family background-color Sets decoration added to text Specifies the font family for text Sets the background color of an element underline, overline, line-through, none Generic font names or descriptions ( times, courier, arial, serif, cursive ) Color names (red, green, teal) or hexadecimal values (#ffffff, #FFCC33)

Other CSS properties you might find interesting are those relating to an element s position on a page ( top, bottom, left, right, and position ) and cursor (which specifies the type of cursor to display). A large list of CSS properties (and brief descriptions of what they do) can be found at w3schools. Great, so which selector should I use? There s no right answer! However, as a general rule: Select by tag when you want to apply the same style to everything with a specific tag. Example: Make paragraphs red and right-aligned p { color: red; text-align: right; Select by class when you want to apply the same style to multiple elements that don t have the same tag, or multiple elements with the same tag but not EVERY element with that tag. Example: Given a page with six headings ( <h2> tags), make the first, third, and fifth appear on yellow backgrounds. Assuming the first, third, and fifth headings have class= odd-heading :.odd-heading { background-color: yellow; Select by ID when you need a style once only (any more than that and you re repeating yourself when you could use a different selector instead). Example : Make the second paragraph of this page use a 35px font. Assuming the second paragraph has id= second : #second { font-size: 35px; Note that there is a hierarchy to selector importance. For instance, ID has a higher

importance than class, which means that if your class says a given paragraph should have green text but your ID says it should have blue, then that paragraph will ultimately have blue text. Adding CSS to HTML pages There are two ways to include CSS in HTML pages: 1. Embed it directly in <style> tags. Example: <html> <head> <style type= text/css > p { color : red;.bold { font-weight: bold; #this { text-decoration: overline; </style> </head> <body> <p> <span id= this >This</span> is some <span class= bold >bold</span> text! </p> </body> </head> 2. ( Preferred) Write CSS in a separate.css file, then link it in the HTML page header. To do this: a. Create a file with the.css file extension (such as myfilename.css) in the same folder where your.html file is saved. b. Inside the <head> tag of every HTML page you want to use that CSS for, add a link tag telling the browser to load your file and treat it as CSS. This looks something like: <link rel= stylesheet type= text/css

href= myfilename.css />. Note: The above link only works if the css file myfilename.css is in the same folder as the html file. If the css file is one folder above the html file, then the link would look like: <link rel= stylesheet type= text/css href=../myfilename.css />. This is preferred not only because it allows you to keep your HTML and CSS separate from each other but also because it lets you reuse the same CSS in multiple places without having to copy-paste (and if you need to change it, you change it once instead of however many times you copied it). A Few (small) Things to Remember Lines that set a property must end with a semicolon (;) in CSS. Styles are inherited by everything within a tag, unless overridden by a more specific style - so styles defined on the <body> tag will be applied to everything on your page unless otherwise specified. Discussion of what makes a style more specific, as well as what is done in other kinds of conflicts (what if you have two CSS files, each of which says paragraphs should be a different color?) can be found on webteacher. Task 1: Reading CSS Open lab5sample.css and read through it. Then, answer the questions at the bottom. Task 2: Writing CSS We ve provided you with an HTML template file for this lab to save a little time. 1. Open lab5template.html in the text editor of your choice ( Recommended: Sublime or Notepad++) and replace the template text with your own content to create a web page about a topic of your choosing. Feel free to add more HTML elements if you so desire. 2. Create a separate CSS file called lab5.css. Add some styles to lab5.css so that it meets the requirements below. Don t forget to link your HTML page to your css! You may find it useful/necessary to add IDs and/or classes to some of the provided HTML elements. Check-off Requirements Have correct answers to the six questions in lab5sample.css.

Have the files lab5template.html containing your modifications to the provided template and lab5.css containing your CSS. Within lab5.css, use at least two of the three types of selectors (tag, class, ID) and both types of colors (names and hexadecimal values). Within lab5.css, have defined styles such that your web page displays the following: Submission a. Paragraph text should be yellow on a black background, except in the second paragraph, where it should be red on a pink background. b. All headings (regardless of size) should be bolded. c. Some text within a paragraph is not the same size as the text around it. d. Some text within a paragraph (but not the same text as in part c.) is not the same font as the text around it. e. Some text within a paragraph (but not the same text as in parts c. or d.) is bolder than the text around it. To submit this lab, please raise your hand so a TA can come check your work. Make sure you tell the TA to check you off their list, or else you will not receive credit. If you do not finish your lab in the allotted time, please either come to office hours or another lab section to finish your work. If you are unable to complete this lab due to sickness or injury, please contact BOTH Don and the cs002 TAs via email. Please contact the cs002 TA s if you have any further questions. cs002 TA Email: cs002tas@cs.brown.edu Don Stanford s Email: don.stanford@gmail.com