CS3220 Web and Internet Programming CSS Basics

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. What is CSS? CSS stands for Cascading Style Sheets (the page—or sheet—helps you create a style that will cascade across all.
Advertisements

Web Engineering 1 Ishaq Khan Shinwari MCS City University Peshawar.
CSS Digital Media: Communication and design 2007.
Cascading Style Sheets (CSS): Pixel-Level Control with HTML Ease
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
HyperText Markup Language (HTML) Uses plain text to add markup instructions to a file. If you can't produce it with a standard keyboard, it can't go into.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
Building a Website: Cascading Style Sheets (CSS) Fall 2013.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
Cascading Style Sheet CSS CS1520 Ali Alanjawi. 2 TA Information Ali Alanjawi Homepage: Office:
CSS(Cascading Style Sheets )
Part 3 Introduction to CSS. CSS Text Text Styles h1 {color: green} // rgb(0,255,0), #00ff00 h2{letter-spacing: 0.5cm} // 2px h3 {text-align: right} //
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
Tutorial 5 Formatting with CSS. Objectives Session 5.1 – Evaluate why CSS styles are used – Determine where to write styles – Create an element selector.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
ALBERT WAVERING BOBBY SENG. Week 2: HTML + CSS  Quiz  Announcements/questions/etc  Some functional HTML elements.
CSS Cascading Style Sheets *referenced from
Chapter 11 & 12 CSS Style Sheets: Intro. Why CSS? Separate presentation from content – more accessible Less work – can change appearance of whole site.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
WebD Introduction to CSS By Manik Rastogi.
CSS.
Cascading Style Sheets
HTML WITH CSS.
CSS for Styling By Jinzhu Gao.
Cascading Style Sheets Color and Font Properties
The Internet 10/11/11 Fonts and Colors
( Cascading style sheet )
Creating Your Own Webpage
Introducing :CSS Cascading Style Sheets in 5 Lessons.
Cascading Style Sheets
Using Cascading Style Sheets Module B: CSS Structure
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
3 Configuring Color & Text With CSS.
Introduction to CSS.
Introduction to Web programming
CSS – Properties & Values
CS 174: Server-Side Web Programming February 7 Class Meeting
The Internet 10/13/11 The Box Model
Cascading Style Sheets
CMPE 280 Web UI Design and Development September 4 Class Meeting
CSS Style Sheets: Intro
Cascading Style Sheets Color and Font Properties
Cascading Style Sheets
What are Cascading Stylesheets (CSS)?
Cascading Style Sheets
Web Development & Design Foundations with H T M L 5
CS3220 Web and Internet Programming CSS Basics
CMPE 280 Web UI Design and Development February 7 Class Meeting
CS3220 Web and Internet Programming CSS Basics
Cascading Style sheet. What is CSS?  CSS stands for Cascading Style Sheets  Cascading: refers to the procedure that determines which style will apply.
Lesson 5 Topic B – Basic Text & Fonts
Cascading Style Sheets
Cascading Style Sheets
Cascading Style Sheets
Session IV Chapter 15 - How Work with Fonts and Printing
Cascading Style Sheets
Introduction to Cascading Style Sheets (CSS)
Cascading Style Sheets
Cascading Style Sheets™ (CSS)
Cascading Style Sheets
CMPE 280 Web UI Design and Development September 5 Class Meeting
Cascading Style Sheets
Presentation transcript:

CS3220 Web and Internet Programming CSS Basics Chengyu Sun California State University, Los Angeles

CSS Cascading Style Sheets A language to describe how HTML elements should be displayed

HTML The Old Way What if your website has 100 tables? Structural Element Presentation Information <table border=“1” cellpadding=“2”> What if your website has 100 tables? What if you want to change the look of all the tables? What if you want the tables to be displayed differently on mobile devices?

Separate Different Aspects of a Web Page Content Structure Procedure Presentation Text, Images, etc. HTML JavaScript CSS

The Benefits of CSS It’s much easier to create and maintain a consistent style for a website It’s much easier to adapt the presentation of a website on different media/devices Smaller documents lead to faster download and better user experience

A Simple CSS Example HTML <p>This is a paragraph.</p> CSS Ruleset p {color: red; font-size: 200%;}

Anatomy of a CSS Ruleset Selector Declaration p { color: red; font-size: 200%; } Declaration Block Property Property Value

Three Ways to Include CSS in a Web Page External stylesheet Internal stylesheet Inline style Recommended Structure and presentation are not properly separated

External and Internal Stylesheet External stylesheet <link rel="stylesheet" href="style.css"> Internal stylesheet <style> p {color: red; font-size: 200%;} </style> Both <link> and <style> should be inside <head>.

Inline Style <p style=“color: red; font-size: 200%;”> Some text.

What Happens When Multiple Style Rules Apply? The Cascading part of CSS determines which rule “wins” Importance Specificity Source order The easy way to check is to use the Developer Tools provide by browsers like Chrome and Firefox

Basic Selectors By element name By ID By Class By attribute p By ID #p1 By Class .blue By attribute a[href] input[type=“text”] Multiple selectors h1,h2,h3 p,#p1,.blue The Universal Selector *

Styling Text Font and color Indentation and alignment Transformation and decoration

Font Family font-family: Helvetica, Arial, sans-serif; font-family: “Courier New”, Courier, monospace; font-family usually includes a list of fonts, and the browser will use the first available font on the list The general convention is to specify a preferred font, a web-safe font, and a generic font

Generic Fonts serif Fonts that have serifs sans-serif Fonts that don’t have serifs monospace Fonts where every character has the same width cursive Fonts that are intended to emulate handwriting fantasy Fonts that are intended to be decorative.

Some Web-Safe Fonts Arial (sans-serif) Courier New (monospace) Georgia (serif) Times New Roman (serif) Trebuchet MS (sans-serif) Verdana (sans-serif)

Font Size font-size: 16px; /* in pixels */ font-size: 12pt; /* in points */ font-size: 150%; /* as a percent of the parent element’s font size */ font-size: 1.5em; /* same as 150% */

Common Units of Measure px: pixels pt: points; one point is 1/72 of an inch %: percent relative to the current font em: one em is equal to the font size for the current font

Colors color is for foreground, background-color is for background color: red; /* using color names */ color: rgb(128, 64, 64); /* using RGB values */ color: #cd5c5c; /* using hexadecimal value */ color is for foreground, background-color is for background

About Colors More color names in https://www.w3.org/TR/css3-color/ RGB values are between 0-255 Hexadecimal values are between 00-FF There could be an additional A value for transparency between 0.0 (fully transparent) to 1.0 (fully opaque)

Other Font Properties font-style: normal, italic, oblique font-weight: normal, bold, 100-900 font-variant: normal, small-caps line-height font: [style] [weight] [variant] size[/line-height] family;

Indentation and Alignment text-indent: indentation of the first line text-align: horizontal alignment left, center, right, justify vertical-align: vertical alignment baseline, top, middle, bottom

Text Transformation and Decoration uppercase, lowercase, capitalize, none text-decoration underline, overline, line-through, blink, none