CSS for Styling By Jinzhu Gao.

Slides:



Advertisements
Similar presentations
Table, List, Blocks, Inline Style
Advertisements

HIGH LEVEL OVERVIEW: CSS CSS SYNTAX CONSISTS OF A SET OF RULES THAT HAVE 3 PARTS: A SELECTOR, A PROPERTY, AND A VALUE. IT’S NOT NECESSARY TO REMEMBER THIS.
Intro To Cascading Style Sheets By Mario Yannakakis.
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.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Cascading Style Sheets
Cascading Style Sheets
/k/k 1212 Cascading Style Sheets Part one Marko Boon
Today CSS HTML A project.
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
Introduction to CSS.
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.
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.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
กระบวนวิชา 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.
CSS Cascading Style Sheets Brief Introduction
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
Learning HTML. HTML Attributes HTML elements can have attributes Attributes provide additional information about an element Class – specifies a class.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
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.
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
CSS.
Cascading Style Sheets
HTML WITH CSS.
CSE 154 Lecture 17: HTML tables.
CS3220 Web and Internet Programming CSS Basics
Cascading Style Sheets Color and Font Properties
The Internet 10/11/11 Fonts and Colors
4.01 Cascading Style Sheets
( Cascading style sheet )
HTML WITH CSS.
Creating Your Own Webpage
Introduction to the Internet
Madam Hazwani binti Rahmat
Using Cascading Style Sheets Module B: CSS Structure
Cascading Style Sheets
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
Cascading Style Sheet (CSS)
Web Systems & Technologies
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Introduction to CSS.
Introduction to Web programming
The Internet 10/13/11 The Box Model
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
CSS Style Sheets: Intro
Lecture 25: SQL and HTML tables
Stylin’ with CSS.
Cascading Style Sheets Color and Font Properties
Cascading Style Sheets
Web Development & Design Foundations with H T M L 5
SEEM4570 Tutorial 3: CSS + CSS3.0
Tutorial 3 Working with Cascading Style Sheets
CS3220 Web and Internet Programming CSS Basics
CS3220 Web and Internet Programming CSS Basics
Stylin’ with CSS.
Cascading Style Sheets
4.01 Cascading Style Sheets
Web Client Side Technologies Raneem Qaddoura
Stylin’ with CSS.
Web Programming and Design
CGS 3066: Web Programming and Design Fall 2019
Presentation transcript:

CSS for Styling By Jinzhu Gao

Web Page A well-written web page: HTML: the content of the document Style Sheets (in CSS): the appearance of the document Scripts (in languages such as JavaScript): the behavior of the document www.webstepbook.com

Old-school formatting (Bad!) The elements such as b, i, u, and font are discouraged in strict HTML Why? Solution: use CSS Because they describe appearance and formatting rather than content www.webstepbook.com

Cascading Style Sheets (CSS) The core language for styling web pages Properties of an element cascade together in this order: browser's default styles external style sheet files (in a <link> tag) internal style sheets (in a <style> tag in the page header) inline style (the style attribute of an HTML element) Describes the way the contents (such as headings, paragraphs, images, lists) should look, such as colors, fonts, and alignment. CSS Zen Garden www.webstepbook.com

Cascading Style Sheets (CSS) Three ways to add CSS info to a web page: Inline with an individual HTML element with a style attribute Embedded in the page’s head section as a style element Placed into an external .css file and applied to the page using the link element Which one to use? Why? Answer: The CSS content is completely separated from the HTML, clean pages, easier to read and more conceptually pure Can be used by many HTML documents www.webstepbook.com

CSS Syntax A CSS file contains one or more rules and each rule consists of one or more selectors Rule: a CSS statement describing a set of page tags and a set of styles to apply to those tags. Selector: describe which content the style applies to. Property: a stylistic aspect that can be set in a CSS rule. www.webstepbook.com

Color Properties Property color background-color Description Element’s foreground(text) color Element’s background color Value A color (specified as a name[aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow], RGB [red, green, and blue values from 0 (none) to 255 (full)], or hex [RGB values in base-16 from 00 (0, none) to FF (255, full)]) www.webstepbook.com

Font Properties Property Description Value font-family Font name to use A name such as serif, sans-serif, cursive, fantasy, monospace font-size Size of text to display A unit value, percentage, or named value font-style Whether or not to italicize text normal (default), italic font-weight Whether or not to bold text normal (default), bold www.webstepbook.com

Text Properties CSS Property Description Values text-align Alignment of inline content left, center, right ,justify text-indent Indent first line A size (px, pt, %, em) text-decoration Underline, etc. underline, overline, line-through, blink, none letter-spacing Horizontal gap between letters line-height Vertical size of each line word-spacing Horizontal gap between words www.webstepbook.com

Grouping Styles www.webstepbook.com

CSS comments www.webstepbook.com

Self-Check What’s wrong with the following CSS code? Identify at least four syntax errors or mistakes. p { background-color: red; foreground color: yellow; Font-Family: Times New Roman, serif; } h1, h2, h3, { font-style: bold; font-size: 24em; No “foreground color”, just “color” Should use “Times New Roman” h1, h2, h3 should not have same font style and font size 24em is way too big www.webstepbook.com

Style Inheritance and Conflicts Inheritance: from the outer element to the inner one CSS precedence: The more specific or closely matching selector “wins” When two styles set conflicting values for the same property, the latter style takes precedence www.webstepbook.com

IDs and ID Selectors ID: ID Selector An attribute uniquely identifying a HTML element Begin with a letter followed by letters, digits, hyphens, underscores, colons and periods (no spaces) Must be unique throughout the document ID Selector A CSS rule that applies only to a particular element on the page with a given ID. Contains a hash sign (#) followed by the id <h2 id=“europe”>Europe</h2> #europe { font-style: italic; } www.webstepbook.com

Links to Selections of a Page www.webstepbook.com

Classes and Class Selectors Class attribute: an identifier that can be attached to any HTML element Multiple elements can have the same class value Class selector: a CSS rule that applies only to particular element(s) on the page that have a given class www.webstepbook.com

CSS pseudo-classes www.webstepbook.com

CSS for Lists www.webstepbook.com

CSS properties for backgrounds Property Description background-color Color to fill background background-image Image to place in background background-position Placement of bg image within element background-repeat Whether/how bg image should be repeated background-attachment Whether bg image scrolls with page background Shorthand to set all background properties www.webstepbook.com

Styling Tables All standard CSS styles can be applied to a table, row, or cell Table specific CSS properties: border-collapse, border-spacing, caption-side, empty-cells, table- layout www.webstepbook.com

The border-collapse property By default, the overall table has a separate border from each cell inside The border-collapse property merges these borders into one Without border-collapse With border-collapse www.webstepbook.com

The rowspan and colspan attributes colspan makes a cell occupy multiple columns rowspan multiple rows text-align and vertical-align control where the text appears within a cell www.webstepbook.com

Column styles: <col>, <colgroup> col tag can be used to define styles that apply to an entire column (self-closing) colgroup tag applies a style to a group of columns (NOT self- closing) www.webstepbook.com

Don’t use tables for layout! (borderless) tables appear to be an easy way to achieve grid-like page layouts many "newbie" web pages do this but, a table has semantics; it should be used only to represent an actual table of data instead of tables, use divs, widths/margins, floats, etc. to perform layout www.webstepbook.com

CSS 3 New Feature New selectors: nth-child, inline-block, :not, + ability to embed fonts in a page (yay) easy built-in support for multi-column layouts transparency/opacity, color gradients, shadows rounded corners/borders animations and transitions (like Scriptaculous) affine transformations (scaling, rotation, perspective) www.webstepbook.com

jigsaw.w3.org/css-validator/ W3C CSS Validator jigsaw.w3.org/css-validator/ www.webstepbook.com

Self-Check Page 78-79 Reading assignment: Section 3.4 Case Study: Traveler Times www.webstepbook.com

Summary CSS properties for colors, fonts and other text properties Style inheritance and confliction HTML id attribute and class attribute www.webstepbook.com