Formatting Text (Plus More Selectors) Learning Web Design: Chapter 12.

Slides:



Advertisements
Similar presentations
Cascading Style Sheets Basics. Why use Cascading Style Sheets? Allows you to set up a series of rules for all pages in a site. The series may be changed.
Advertisements

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} //
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
Session Objectives Setting the font family Setting the font size Working with Web fonts Setting font faces and sizes Setting font and text appearances.
Week 7 Web Typography. 2 Understanding Type Design Principles.
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
1 CSS Styling with Fonts and Colors. 2 CSS Cascading Style Sheets and fonts CSS provides Style or Presentation options for our html pages CSS properties.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Cascading Style Sheet (CSS) Instructor: Dr. Fang (Daisy) Tang
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
© 2007 D. J. Foreman CSS-1 Cascading Style Sheets Styles.
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
+ Text & Font Styles Unit 3 Lesson Different Font Categories Sans Serif – block style fonts Example - Rockwell Easy to read and good to use when.
Web Design – Sec 4-6 and 4-7 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
CSS: Cascading Style Sheets. 2 History HTML tags were originally designed to define the content of a document. The layout of the document was supposed.
CSS1-1 Cascading Style Sheets (CSS) Xingquan (Hill) Zhu
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
Principles of Web Design 6 th Edition Chapter 5 – Web Typography.
Cascading Style Sheet (CSS)
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
WORKING WITH CASCADING
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
XP New Perspectives on XML Tutorial 5 1 TUTORIAL 5 CSS Tutorial – Carey ISBN
Typography.  Introduction to Typography  Font Collections ▪ Serif ▪ They have small strokes at the end of the character strokes ▪ Ex: Times New Roman,
INTRODUCTION TO HTML5 Styling Text. Change the Font Size  You can use the font-size property to change the font size for a document’s text.  Instead.
CSS: Cascading Style Sheets. 2 What are Style Sheets A style sheet is a mechanism that allows to specify how HTML (/XHTML/XML) pages should look The style.
 A style sheet is a single page of formatting instructions that can control the appearance of many HTML pages at once.  If style sheets accomplished.
Cascading Style Sheets Chapter Four. What are they? A set of style rules that tell the web browser how to present a web page or document. Cascading Style.
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.
MySQL and PHP Review CSS. Cascading Style Sheet (CSS) Style sheets are files or forms that describe the layout and appearance of a document. Cascading.
Basics of Web Design Chapter 6 More CSS Basics Key Concepts.
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
1 Web Development CSS (Cascading Style Sheet). 2 1.Setting rules for multiple elements To decrease the amount of typing for setting rules for multiple.
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
Cascading Style Sheets Web Design Fairport High School.
CSS properties Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Developing Web Applications with HTML and CSS “Selectors and Properties”
Web Design (14) CSS Formatting Text. Formatting Text In Brackets, go to your ‘externalcss’ website and find the ‘formattingtext’ page. Use the ‘main’
CSS: Cascading Style Sheets Part II. Style Syntax.
CSS Cascading Style Sheets *referenced from
Creating Layouts with CSS. Span tag Here is some underlined text. Here is some blinking text. Here's some bold text.
Tutorial 3 Designing a Web Page with CSS
03 CSS (Cascading StyleSheet) Р.Жавхлан МОНГОЛ УЛСЫН ИХ СУРГУУЛЬ Мэдээллийн технологийн сургууль Интернэт технологийн үндэс 2015 Намар.
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.
1 CS428 Web Engineering Lecture 07 Font, Text & Background (CSS - II)
Formatting Text with HTML and CSS. Summary block-level elements. Character-level elements Logical and physical style Special elements: hr,address, quotation.
CSS Details Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  To use CSS properties for fonts  Evaluate whether to use pts,
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 10: Formatting Text with Styles.
Cascading Style Sheets Robin Burke ECT 270. Outline CSS properties Fonts Alignment Color CSS selection selectors.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
Internet & World Wide Web How to Program, 5/e 1. 2.
Cascading Style Sheets
CS3220 Web and Internet Programming CSS Basics
Introducing :CSS Cascading Style Sheets in 5 Lessons.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
CSS – Properties & Values
CSS Style Sheets: Intro
CS3220 Web and Internet Programming CSS Basics
CS3220 Web and Internet Programming CSS Basics
Cascading Style Sheets™ (CSS)
Cascading Style Sheets
Presentation transcript:

Formatting Text (Plus More Selectors) Learning Web Design: Chapter 12

Lesson Overview Learn how to specify the formatting of text using CSS Learn about the font-related properties Understand text line setting such as line height, indents, and alignment Understand the basics of text color, underlines, and capitalization Learn more about various selector types and specificity

Styling Textual Elements One of the first things a Web designer does is make decisions about the appearance of textual elements on the site The font properties are an important part of the presentational layer and should be controlled by style sheets Do not take text formatting lightly, it can be an important part of branding a Web site

The Font CSS Properties You will learn to make use of a set of font-related properties to specify the appearance of textual elements If you do not specify a property, the default browser styles will be applied to your text We will also discuss the font limitations we have with Web design that print designers do not deal with

The Font-Family Property The font-family property changes the general family of the text or typeface p {font-family: Arial;} All font names except generic fonts must be capitalized Font names with two words must be enclosed in “ ” p { font-family: “Trebuchet MS”;}

Using a Font-Family List Only typefaces that are available on a user’s (client) machine can be displayed A list of font-families can be given to make sure if the first one is not found, then the next will be displayed, etc. Often the list of fonts is given for different platforms like: PC font, Mac font, generic font For example: p {font-family: Arial, Helvetica, sans-serif; }

Generic Font Families The font-family property can be used to set one of the five generic font families: serif, sans-serif, cursive, fantasy and monospace These generic font families are used as defaults and often appear at the end of font-family lists For sans-serif, this means as a last option use some kind of sans-serif font The names of these generic font families are not capitalized

Serif vs Sans-Serif Fonts serif typefaces have decorative serifs or appendages on the ends of certain letter strokes Examples: Times New Roman, Georgia sans-serif typefaces have straight letter strokes without serifs Considered to be more readable on a computer screen Examples: Arial, Verdana, Lucinda Sans

Monospace, Cursive and Fantasy Monospace fonts have a constant width for all characters in the typeface Examples: Courier, Monotype Corsiva Cursive fonts emulate script or handwriting and are rarely used on professional pages Examples: Comic Sans, Vivaldi Fantasy fonts are decorative in nature and are also rarely used because of poor legibility Examples: Impact, Chiller

The Font-Size Property Specifying font-size can be done with many different units of measure For example: This font is normal sized This font is twice as tall This font is 12 pixels tall

Units of Measure in CSS em - Relative: font’s character height ex - Relative: height of font’s x character px - Relative: pixels of a monitor screen % - Relative: percentage values in - Absolute: inches cm - Absolute: centimeters mm - Absolute: millimeters pt - Absolute: points pc - Absolute: picas Preferred Avoid These

Working with Keywords Font-size can be specified using the keywords: xx-small, x-small, small, medium, large, x-large, xx-large Default size on most browsers is medium The keywords do not correspond to any measurement, but are scaled in relation to one another Keywords larger and smaller shift size of text in relation to size of parent element

Working with % and em A popular way to specify a font-size is em measurements or % or some combination These are relative font measurements based on the parent element’s font-size If no font-size for parent given, em and % are based on browser’s base font size Once the em size is calculated, it can be used for all kinds of measurements indents, margins, widths etc.

The Font-Weight Property The font-weight property modifies the weight normal, bold, bolder, lighter 100, 200, 300, 400, 500, 600, 700, 800, 900 Most fonts common to the Web only have two weights: normal and bold Numeric values lower than 600 are usually normal and 600 and above are usually bold For example: p {font-weight: bold; } p { font-weight: 600;}

The Font-Style Property The font-style property affects whether the letter shapes are vertical (normal) or slanted (italic or oblique) italic, oblique are slanted versions of a font The italic version is usually a separate typeface The oblique version uses normal font and slants it in the browser Examples: p { font-style: italic;} p { font-style: normal;}

The Font-Variant Property The font-variant property makes use of the small uppercase style letters available in some typefaces When a true small caps font is not available, the browser will scale down uppercase letters so you see them as small caps Examples: h1 { font-variant: small-caps;} h1 { font-variant: normal;}

The Line-Height Property The line-height property defines the minimum distance from baseline to baseline in text Baseline is the imaginary line on which bottoms of characters sit Values include: number, length measurement, percentage, or normal Examples: { line-height: 2;} (number acts as a scaling factor) { line-height: 2em;} (twice the height of an em} { line-height: 200%;} (twice the height of base font)

The Shortcut Font Property A shortcut property called font can be used to apply many font properties at once The font values are given in this order: {font: style weight variant size/line-height font-family } As a minimum font values need: {font: font-size font-family}

The Text-Decoration Property Used to apply a decoration to text within the affected tag Values include: none, underline, over-line, line-through, and blink Some examples: p {text-decoration: underline;} p {text-decoration: line-through;} p {text-decoration: none;}

Cautions with Text-Decoration The most common use of the text-decoration property is to turn off the underline under hypertext : a { text-decoration: none; } Be sure there are other clues to compensate such as color or weight if you turn off underline on links Adding underline to text may mistakenly lead user into thinking the text is a link Blinking text can be annoying and amateurish. Internet Explorer does not support blink.

The Text-Indent Property The text-indent allows the first line of text to be indented by specified amount Only the first line is indented Values include: length measurement or percentage Negative values can create a hanging indent Examples: p { text-indent: 2em;} (twice size of em) p { text-indent: 25%;} (25% width page)

The Text-Transform Property If you want to change the capitalization of text on the fly, you can apply the text-transform property Values include: none, capitalize, lowercase, uppercase Examples: p{ text-transform: none} (text same as typed) p{ text-transform: capitalize} (first letters capitalized) p{ text-transform: lowercase} (all letters lowercased) p{ text-transform: uppercase} (all letters uppercased)

Letter and Word Spacing The letter-spacing property inserts space between each letter in the text The word-spacing property inserts space between each word in the text Values include: length measurement and normal Examples: p { letter-spacing: 8px;} (each letter spaced) p { word-spacing: 1.5em;} (each word spaced)

The Text-Align Property The text-align property allows you to horizontally align text to the margin or margins of a Web page Values include: left, right, center, justify Examples: p{ text-align: left;} (aligns to left margin) p{ text-align: right;} (aligns to right margin) p{ text-align: center;} (centers between margins) p{ text-align: justify;} (aligns on both margins)

Classes in CSS Sometimes you will need to create your own user-defined style rule for use anywhere on the page. A class style rule can be applied many times on a Web page Begin the class style with a. character and then the name of the new class Example:.bigger { font-size: larger; }

Applying a Class This new class allows you to group several styles and apply them to an element or text anywhere on your page. Use the class attribute to apply the class style rule (do not use the. with the name) Ex. Text inside tag Ex. A paragraph of text contains many words inside sentences.

Use IDs for Unique Styles When you want a specific style for one element on a page, assign it to an ID. To create a rule to work with an ID, use the # character when you define the style rule Example: # footer { font-size: small; } To identify the footer on your page, use the id attribute: Copyright 2008

Grouped Selectors One handy style rule short cut is to create a style rule for more than one element type A comma-separated list of selectors is used with the declaration block h1, h2, p, ul {font-size: small;} This single style rule has the same effect as four separate style rules Using grouped selectors also makes your style sheet more readable

Descendent Selectors in CSS Descendent selectors are a kind of contextual selector they only are applied in a certain context Descendent selectors are used to apply styles to child elements only when they are nested within a certain parent Example: div ol { font-size: 125%; } Only applies the font-size of 125% to an child element nested inside a parent element

More on Specificity in CSS Some selectors have more weight than others when it comes to resolving conflicting style rules: the most specific style rule wins Order of selectors most specific -> least specific: ID selectors Class selectors Contextual Selectors (includes descendent selectors) Individual Element Selectors

Anchor Pseudo-Classes Anchor pseudo-class allow you to define styles for different link state changes You can determine a pseudo-class style because it contains the : character Links exist in multiple states: a:link – the unvisited link state a:visited – the link has been visited a:hover – the mouse is hovering over the link a:active – the link is active

Ordering Anchor Pseudo Classes The order you place the anchor pseudo- classes in a style sheet is important a:link and a:visited – must appear before the a:hover pseudo-class a:hover – must appear before the a:active pseudo-class Memory clue for pseudo class order: love ha : link, visited, hover, active

Using Anchor Pseudo Classes Using CSS you can change the color and appearance of a link in these states Ex. a: link { color: blue;} a: active { color: red; } a: visited { color: green; } a: hover { color: yellow; } Pseudo-classes can be combined with classes Ex. a.red:visited { color: red;}

Readability Dos Do make use of white space on a page: this allows important elements to stand out Do use the same font-family for all headings: just vary the size Do use relative font sizes: allows the user to choose to increase or decrease the font size Do structure “scannable” pages: Use shorter paragraphs, lists, headings and sub-headings

Readability Don’ts Don’t Center, bold, or italicize entire paragraphs: this makes text harder to read Don’t change font-family or other formatting too much on a page - “Less is more” Don’t use to force line breaks: allow text to wrap when window is resized Don’t use underlined text: users mistake to text for hypertext Don’t use all caps for long headings or paragraphs: harder to read, use for short headings

Just the Beginning The main use of the ID selector is to layout Web pages – Covered in Chapters 14, 15, and 16 Use of text and background colors – Covered more in Chapter 13 External Style Sheets- Covered in Chapters 14, 15, and 16

Lesson Summary While HTML provides many tags and attributes for text formatting many are being deprecated (phased out) Text formatting should be done with Cascading Style Sheets, CSS Use inline CSS sparingly for special case formatting Use embedded CSS for controlling text formatting of an entire Web page