Applying CSS. There are three ways of applying CSS to HTML:

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

Creating a Resume Webpage with

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

ITNP43: HTML Lecture 4

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

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

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

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

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

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

Web Design and Development ACS Chapter 9. Page Structure

Introduction to Adobe Dreamweaver CC

HTML5 and CSS3 Design with CSS Page 1

Web Design with CSS and CSS3. Dr. Jan Stelovsky

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

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

Outline of CSS: Cascading Style Sheets

Introduction to Cascading Style Sheets

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

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

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

Stylesheet or in-line CSS CSS attributes, used in stylesheets or in-line, can define:

Colgate University Website Content Style Guide

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

HTML and CSS. Elliot Davies. April 10th,

Web Authoring CSS. Module Descriptor

Creating Web Pages with Dreamweaver CS 6 and CSS

MCH Strategic Data Best Practices Review

JJY s Joomla 1.5 Template Design Tutorial:

Level 1 - Clients and Markup

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

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

Advanced Editor User s Guide

CIS 467/602-01: Data Visualization

Page layout & typography. graphic design

Microsoft Expression Web Quickstart Guide

LEAGUE OF WOMEN VOTERS NAME & LOGO GUIDELINES

Mobile Web Site Style Guide

customer community Getting started Visual Editor Guide!

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

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

Code View User s Guide

Coding Standards for Web Development

Cascading Style Sheets

Web Design and Databases WD: Class 5: HTML and CSS Part 2

CSS for Page Layout. Key Concepts

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 (

CS134 Web Site Design & Development. Quiz1

Using Style Sheets for Consistency

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

Further web design: Cascading Style Sheets Practical workbook

Base template development guide

Full report on all 24 clients

GUIDE TO CODE KILLER RESPONSIVE S

Web Design I. Spring 2009 Kevin Cole Gallaudet University

CREATING HORIZONTAL NAVIGATION BAR USING ADOBE DREAMWEAVER CS5

Garfield Public Schools Fine & Practical Arts Curriculum Web Design

Graphic Design Basics. Shannon B. Neely. Pacific Northwest National Laboratory Graphics and Multimedia Design Group

ICE: HTML, CSS, and Validation

Responsive Design

Intro to Web Design. ACM UIUC

Click on the links below to find the appropriate place in the document

Cascading Style Sheets (CSS)

Eloqua What is this and why should I read it?

Contents. Introduction Downloading the Data Files... 2

Style Guide Provided courtesy of Innovative Emergency Management Inc.

Creating the Surf Shop website Part3 REVISED

Tips and tricks with Text boxes in Mahara

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

Joomla Article Advanced Topics: Table Layouts

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

Cascading Style Sheets (CSS)

Designing HTML s for Use in the Advanced Editor

ODS for PRINT, REPORT and TABULATE

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

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

Cascading Style Sheets

Using and creating Crosstabs in Crystal Reports Juri Urbainczyk

CSS - Cascading Style Sheets

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

Web layout guidelines for daughter sites of Scotland s Environment

Citywide User Experience Design Guidelines: NYC.gov Style Guide. Final Public 11/8/2013

Web Publishing Basics 2

Microsoft Word 2010 Basics

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

Print all 18 Chapters - CSS Basics

Appendix H: Cascading Style Sheets (CSS)

Using Adobe Dreamweaver CS4 (10.0)

How to Manage Your Eservice Center Knowledge Base

Making Responsive s

LaGuardia Community College Thomson Ave, Long Island City, New York Created by ISMD s Dept. Training Team. Overview

Basic tutorial for Dreamweaver CS5

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

HTML, CSS, XML, and XSL

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

When older typesetting methods gave

New Perspectives on Creating Web Pages with HTML. Considerations for Text and Graphical Tables. A Graphical Table. Using Fixed-Width Fonts

Selectors in Action LESSON 3

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

Transcription:

Basic CSS

Introduction CSS, or Cascading Styles Sheets are a way to style HTML HTML should be used for the content, and the style sheet for the presentation of your document Styles have a format of property: value and most properties can be applied to most HTML tags

Applying CSS There are three ways of applying CSS to HTML: Inline Internal External The preferred approach is to have the HTML document be presentation free, and so inline and internal styles should be avoided whenever possible.

Inline In-line styles are placed straight into the HTML tags using the style attribute. For example, the following style attribute of the paragraph tag will make the whole paragraph red: <p style="color: red">content</p>

Internal Internal styles affect a whole page. The style element is put inside the head of the document, and it specifies all of the styles for the page. The following internal style specification will make all of the paragraphs in the page red and all of the links blue: <head> <title>css Example</title> <style type="text/css">p {color: red;} a {color: blue;}</style> </head>

External External styles are used for the whole, multiple-page website. They are put in a separate CSS file and linked to the HTML files.

External The external style sheet can look something like this: p {color: red;} a {color: blue;} It doesn t need any special additional syntax Can be written in a text editor like Notepad, and saved as something.css

Linking External CSS Once the external style sheet is completed, it can be linked to the HTML document like this: <head> <title>css Example</title> <link rel="stylesheet" type="text/css" href="something.css"> </head>

CSS syntax Instead of tags, CSS has selectors. Selectors are the names given to styles in internal and external style sheets. We will focus on HTML selectors, which are simply the names of HTML tags and are used to change the style of a specific tag. For each selector there are properties inside curly brackets, which simply take the form of words such as color, font-weight or background-color. A value is given to the property following a colon and semi-colons separate the properties.

Example body {font-size: 12px; color: blue;} This will apply the given values to the font-size and color properties of the body selector. So when this is applied to an HTML document, all text between the body tags (which is all text in the window) will be 12 pixels in size and blue in color.

Length values There are many property-specific units for values used in CSS, but there are some general units that are used in a number of properties. em is an element approximately equal to the height of a character (font-size: 2em). px is the unit for pixels (font-size: 12px). pt is the unit for points (font-size: 12pt). % is the unit for percentages (font-size: 50%). Furthermore, cm is for centimeters, mm for millimeters and in for inches.

Zero value When a value is zero, you do not need to state a unit. For example, if you want to specify no border, use border: 0.

Preferred Units A web page is meant to be flexible. Users should be allowed to view the web page however they like, which includes the font size and the size of the screen. Hence, it is generally accepted that em and % are the best units to use for font sizes, heights and widths rather than px. px leads to non-resizable text in most browsers, and should be used sparingly, for example in border sizes.

Colors CSS has 16,777,216 different colors. They can take the form of a name, an rgb (red/green/blue) value or a hex (hexadecimal) code. red Is the same as rgb(255,0,0) Is the same as rgb(100%,0%,0%) Is the same as #ff0000 Is the same as #f00

Colors There are many predefined color names, like: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow. transparent is also a valid value.

Colors The three values in the rgb value range from 0 to 255, 0 being the lowest level, 255 being the highest level. These values can also be expressed as a percentage. Hexadecimal is the base-16 number system. Hex numbers are defined by a hash character (#) and can be three or six digits long. The three-digit version is a compressed version of the six-digit (for example, #f00 becomes #ff0000) The three-digit version is easier to decipher but the sixdigit version gives you more control over the exact color.

Colors Colors can be applied using color and backgroundcolor A blue background and yellow text would look like this: h1 {color: yellow; background-color: blue;} Usually, you don t want to use harsh, contrasting colors h1 {color: #ffc; background-color: #009;} is better. You can apply the color and background-color properties to most HTML elements, including body, which will change the colors of the page and everything in it.

Text You can alter the size and shape of the text on a web page with the following properties: font-family font-size font-weight font-style text-decoration text-transform

font-family This specifies the font, such as Times New Roman, Arial or Verdana. The font you specify must be on the user s computer, so you shouldn t use obscure or fancy fonts. There are some safe fonts (the most commonly used are Arial, Verdana and Times New Roman), but you can specify more than one font, separated by commas. The purpose of this is that if the user does not have the first font you specified, the browser will go through the list until it finds one that it does have. This is useful because different computers can have different fonts installed.

font-family For example, font-family: arial, helvetica, will assure that similar fonts are used on PC and Mac (the two fonts look similar, and PCs usually have arial but not helvetica, and Macs usually don t have arial, but have helvetica). If the name of a font is more than one word, it should be put in quotation marks, such as font-family: "Times New Roman".

font-size Specifies the size of the font. Headings should not be regular paragraph text in a large font: you should use h1, h2 etc. Likewise, if you want to make regular paragraph text larger, don t use headings: use font-size.

font-weight Specifies whether the text is bold or not. Can take values normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800 or 900 However, some browsers don t display this. Also, it can get confusing and annoying to have many different font weights, so it s best to stick with only bold and normal. font-weight: bold font-weight: normal

font-style Specifies whether the text is italic or not. font-style: italic font-style: normal

About font weight and style Instead of font-weight and font-style, you can also use the <strong> and <em> tags in the HTML document. Generally, font-weight and font-style are used for changing a longer piece of text (like a paragraph or the whole page), and <strong> and <em> are used for changing a short piece of text (like a word or phrase).

text-decoration Specifies an whether the text is underlined or not. text-decoration: overline places a line above the text text-decoration: line-through puts a line through the text text-decoration: underline underlines the text; this should only be used for links because users generally expect underlined text to be a link The text-decoration property is usually used to decorate links, in particular specifying no underline with textdecoration: none.

text-transform Specifies the case of the text. text-transform: capitalize turns the first letter of every word into uppercase. text-transform: uppercase turns everything into uppercase. text-transform: lowercase turns everything into lowercase. text-transform: none makes no transformation.

Example body {font-family: arial, helvetica, sans-serif; font-size: 0.8em;} h1 {font-size: 2em;} h2 {font-size: 1.5em;} a {text-decoration: none;} strong {font-style: italic; text-transform: uppercase;}

Text spacing The letter-spacing and word-spacing properties are for spacing between letters and words. The value can be a length or normal. The line-height property sets the height of the lines in an element (like a paragraph) without adjusting the size of the font. It can be a length, a percentage, or normal. The text-align property will align the text inside an element to left, right, center or justify. The text-indent property will indent the first line of a paragraph to a given length or percentage. It is more common to separate paragraphs by a blank space than by indentation, since indentation is usually used in print, and rarely in digital media.

Example p { letter-spacing: 0.5em; word-spacing: 2em; line-height: 1.5em; text-align: center; }

Margins and padding margin and padding are two commonly used properties for spacing-out elements. A margin is the space outside of an element. Padding is the space inside an element.

Example If we change the code for h2 to the following, we see that this leaves a one-character-wide space around the header and the header itself is bloated by the three character-wide padding. h2 { font-size: 1.5em; background-color: #ccc; margin: 1em; padding: 3em; }

Borders Borders can be applied to most HTML elements. To make a border around an element, use border-style. The values can be solid, dotted, dashed, double, groove, ridge, inset, outset. border-width sets the width of the border, which is usually in pixels. There are also properties for border-top-width, border-right-width, border-bottom-width and borderleft-width. border-color sets the color of the border.

Example h2 { border-style: dashed; border-width: 3px; border-left-width: 10px; border-right-width: 10px; border-color: red; } This will make a red dashed border around all HTML secondary headers (h2 s) which is 3 pixels wide on the top and bottom and 10 pixels wide on the left and right (these override the 3 pixel wide width of the entire border).