HTML5 and CSS3 Design with CSS Page 1



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

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

ITNP43: HTML Lecture 4

Creating a Resume Webpage with

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

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

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

Web Design with CSS and CSS3. Dr. Jan Stelovsky

Cascading Style Sheets (CSS)

Outline of CSS: Cascading Style Sheets

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

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

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

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

Web Authoring CSS. Module Descriptor

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

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

Introduction to Adobe Dreamweaver CC

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

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

Using Style Sheets for Consistency

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

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

CREATING HORIZONTAL NAVIGATION BAR USING ADOBE DREAMWEAVER CS5

CIS 467/602-01: Data Visualization

CSS - Cascading Style Sheets

ICE: HTML, CSS, and Validation

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

JJY s Joomla 1.5 Template Design Tutorial:

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

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

CST 150 Web Design and Development I Midterm Exam Study Questions Chapters 1-3

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

Garfield Public Schools Fine & Practical Arts Curriculum Web Design

Selectors in Action LESSON 3

Coding Standards for Web Development

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

Web Design and Development ACS Chapter 9. Page Structure

HTML, CSS, XML, and XSL

Creating Web Pages with Dreamweaver CS 6 and CSS

Web Development 1 A4 Project Description Web Architecture

When older typesetting methods gave

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 (

Using an external style sheet with Dreamweaver (CS6)

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

BLACKBOARD 9.1: Text Editor

MCH Strategic Data Best Practices Review

Tips and tricks with Text boxes in Mahara

customer community Getting started Visual Editor Guide!

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

Style & Layout in the web: CSS and Bootstrap

Basic tutorial for Dreamweaver CS5

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

Smartphones and tablets: If you have a data plan, use the SMTP server setting for the company that provides this service.

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

Colgate University Website Content Style Guide

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

CSS for Page Layout. Key Concepts

Cascading Style Sheets

Microsoft Word 2010 Basics

HTML and CSS. Elliot Davies. April 10th,

How to code, test, and validate a web page

Contents. Introduction Downloading the Data Files... 2

How to Properly Compose HTML Code : 1

Mobile Web Site Style Guide

MS Word 2007 practical notes

Responsive Design

Positioning Container Elements

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

Help on Icons and Drop-down Options in Document Editor

EUROPEAN COMPUTER DRIVING LICENCE / INTERNATIONAL COMPUTER DRIVING LICENCE WEB EDITING

Paragraph Formatting 4

General Electric Foundation Computer Center. FrontPage 2003: The Basics

GUIDE TO CODE KILLER RESPONSIVE S

Responsive Web Design: Media Types/Media Queries/Fluid Images

BASICS OF WEB DESIGN CHAPTER 2 HTML BASICS KEY CONCEPTS COPYRIGHT 2013 TERRY ANN MORRIS, ED.D

Web layout guidelines for daughter sites of Scotland s Environment

U T A H V A L L E Y U N I V E R S I T Y

Microsoft Expression Web Quickstart Guide

Table of Contents THE DESIGNER S GUIDE TO CREATING NEWZAPP DRAG AND DROP TEMPLATES... 6 THE NEWZAPP SYSTEM... 7

Further web design: Cascading Style Sheets Practical workbook

Dreamweaver. Introduction to Editing Web Pages

Web Developer Jr - Newbie Course

Formatting Text in Microsoft Word

Advanced Drupal Features and Techniques

HTML TIPS FOR DESIGNING

Using Adobe Dreamweaver CS4 (10.0)

Advanced Editor User s Guide

Advanced Web Design. Zac Van Note.

Transcription:

HTML5 and CSS3 Design with CSS Page 1 1 12 2 3 3 4 45 5 6 6 7 7 HTML5 and CSS3 DESIGN WITH CSS Styles in HTML Documents Styles provide a method of creating consistent formatting of elements throughout an entire website For example is makes it much simpler to format all the headings, paragraphs, list elements, etc. for all the pages in the site so that they are identical in style The style is defined once and applied automatically each time the tag and/or element is used Style Implementations Style sheets may be applied at three different levels: Linked style sheet is created as a separate document file with the extension.css; a <link> tag is placed into each Web page that will implement the style sheet Embedded style sheet is embedded into a single Web page in the <head> section; only the document in which it is embedded is able to use its features in the style list Inline placed at any point in the document <body>; involves including a style attribute inside the tag; the formatting applies only to that tag at that location Try Designing It Out a Style Rule Page 1 Style sheets are written in CSS (Cascading Style Sheet) language and implement Web page formatting and layout selector property1: value1; property2: value2; The selector is the name of an element (e.g. tag) or a group of elements The property is the name of a format type and the value is the value assigned to it Designing a Style Rule Page 2 Examples: text-align: center; font-family: Arial; External Style Sheets A Web page can link to a separate (external) style sheet file Linked style sheets are created as a separate document files with the extension.css; a link tag is placed into each Web page that will implement the style sheet The link tag is placed in the head section <link href = "location/filename" rel = "stylesheet" type = "text/css" /> 8 89

HTML5 and CSS3 Design with CSS Page 2 8 89 9 10 10 11 11 12 12 <link href = "mystyles.css" rel = "stylesheet" type = "text/css" /> Try Embedded It Out Implementation Page 1 Embedded implementation is a method in which the style sheet is embedded into a single web page Only the one Web document in which it is embedded will be able to use the features in the style list Can be useful if the several elements in an individual Web page have a unique style Implemented by placing <style> tag in the <head> section of the document <style type = "text/css"> style_rules </style> Embedded Implementation Page 2 <head> <title>style Sheet Example</title> <style type = "text/css"> a:link color: #400080; background: #FFFFD8 h1 font-weight: bold; text-align: center; color: #006000; font-family: Algerian; </style> </head> Inline Implementation Inline implementation places style sheet formatting at any point in the document <body> Involves including a style attribute inside the tag; the formatting applies only to that tag at that location An advantage of this technique is the closing tag for the element turns off all the style formatting <element style="style_rules"> <p style="color: #FFFF00; font-family: Arial"> Inline implementation is lowest in priority</p> Style Precedence and Specificity Generally a more specific style is implied instead of a more general one E.g. a style applied to a paragraph is applied before one applied to a section For styles implemented at more than one level (inline, embedded, linked) in a website, the order of precedence is: Inline (highest) 13

12 HTML5 and CSS3 Design with CSS Page 3 13 13 14 14 15 15 16 16 17 17 18 18 19 Inline (highest) Embedded Linked (lowest) Comments in Style Sheets Style sheet comments use a form similar to multi-line comments in C++ and Java /* Comment text */ /* Author: Carl B. Struck The "mystyles.css" style sheet */ Try RGB It Colors Out in CSS Color values may be specified as RGB values using the rgb() function specifying the amounts of red, green and blue as integer values between zero (0) and 255 rgb(redn, greenn, bluen) color: rgb(255, 255, 0) Will render as yellow Color Names in CSS There is a list of 140 color names which can substitute for the RGB() function A partial list of the color names include red, pink, black, gray, yellow, blue, orange, white, etc. element: color_name; body background-color: antiquewhite; The color Property Formats the color of text for an element color: rgb(redn, greenn, bluen) color_name; color: rgb(255, 255, 0) The background-color Property Formats the background color behind text for an element background-color: rgb(redn, greenn, bluen) color_name; body background-color: antiquewhite 20

19 20 HTML5 and CSS3 Design with CSS Page 4 20 19 19 20 20 21 21 22 22 23 21 23 21 22 22 23 23 24 24 24 24 25 25 26 26 25 25 26 26 27 Try The It rgba() Out Function The a in rgba() stands for alpha and relates to the amount of transparency in the color in which opacity is a decimal value between zero (0) and one (1) rgb(redn, greenn, bluen, opacity) 100% opacity is solid; 0% is invisible color: rgb(255, 255, 100, 0.7) Opacity in this example is 70% Try Contextual It Out Selectors Page 1 Takes advantage of the hierarchy of elements so that only elements descended (directly or indirectly) from a specific parent type are effected arent descendant styles header h1 Only h1 elements in the header section are effected Contextual Selectors Page 2 Contextual selectors take advantage of the rule that the more specific style takes precedence over the less specific Examples: color: red; header h1 Second example takes precedence over the first Try The It id Out Attribute Selector A style can be applied to an element based on its id A hash (#) symbol precedes the id name in the style rule #id #main Would apply to the h1 heading: <h1 id="main">my Heading</h1> Defining Classes 27

HTML5 and CSS3 Design with CSS Page 5 28 28 28 29 29 29 30 30 31 30 31 31 32 32 32 33 33 33 34 34 35 34 35 35 Using Class Name in a Style Sheet Page 1 The class name following a dot (.) may used as a selector.class styles.mail Using Class Name in a Style Sheet Page 2 The class name may used as a modifier for any selector in a stylesheet which allows styles to be applied selectively to an individual tag or tags element.class styles a.mail Try Choosing It OutText Font The font-family property specifies a comma-separated list of font faces The browser selects the first installed font from the list font-family: fonts Browser selects first installed font from fonts list font-family: 'Arial Black', Arial, sans-serif; Multi-word font names are listed in 'single quotes' Generic Font Groups Describes general appearance of a typeface including: serif small ornamentation at tail end of each character sans-serif font without ornamentation monospace each character has same width as all others cursive mimics handwriting fantasy highly ornamental; not appropriate for body text Web Safe Fonts Displayed mostly the same in all browsers including: Arial, Arial Black, Century Gothic, Comic Sans MS, Courier New, Georgia, Impact, Lucida Console, Lucida Sans Unicode, Tahoma, Times New Roman (the default in many browsers), Trebuchet MS, Verdana Try Setting It Out Font Size Page 1 The font-size property is measured in length which can be specified in one of four ways: With a unit of measure As a percentage of the size of the containing element

HTML5 and CSS3 Design with CSS Page 6 35 36 36 37 37 38 38 39 39 40 40 As a percentage of the size of the containing element With a keyword description With a keyword description that is the size relative to the size of the containing element font-size: size xx-small x-small small medium large x-large xx-large smaller larger; Setting Font Size Page 2 Example (unit of measure): font-size: 2em; Example (percentage of size of containing element): font-size: 75%; Setting Font Size Page 3 Example (keyword description): font-size: x-large; Example (keyword description where size is relative to size of containing element): font-size: smaller; CSS Units of Measure CSS recognizes several units of measure including: % percentage of containing element in (inch) cm (centimeter) mm (millimeter) em 1 em is equivalent to current font size; useful since it can adapt automatically to the font that the reader uses Historically em is equivalent to width of uppercase M t (point) 1 pt is the same as 1/72 of an inch c (pica) 1 pc is the same as 12 points x (pixel) a dot on the computer screen Try Controlling It Out Spacing between Characters The letter-spacing property controls the amount of space between characters (default is no extra space) letter-spacing: value; The value normal is used if an element might be inheriting some other value 41

HTML5 and CSS3 Design with CSS Page 7 41 41 42 42 43 43 44 44 45 45 46 letter-spacing : 10px; Controlling Spacing between Words The word-spacing property controls the amount of space between words (default is no extra space) word-spacing: value; word-spacing : 10px; Controlling Spacing between Lines The line-height property controls the amount of space between lines of text (default is 100%) line-height : size; line-height : 115%; Controlling Indentation The text-indent will indent the element by specified size For a paragraph will indent the first line only text-indent : size; The value initial is used if to return to the default if an element might be inheriting some other value A negative value is used to create a hanging indent text-indent : 115%; Try Setting It Out the Text s Italic Style The font-style property creates italic (sloped) text font-style: normal italic oblique; The italic style generally is cursive while oblique is typically sloped versions of the regular face font-style: italic; Setting the Text s Boldface Property 46

HTML5 and CSS3 Design with CSS Page 8 46 47 48 49 50 Setting the Text s Boldface Property The font-weight property applies boldface to text font-weight: normal bold bolder lighter 100 900; Numeric values between 100 to 900 (in increments of 100's) indicate lighter to heavier weights (some weights may appear identical if fewer than nine weights are installed in browser) font-weight: bold; Setting the Text s Line Property The text-decoration property applies underlining, overlining and strike-through to text text-decoration: underline overline line-through none; h3 text-decoration: line-through; Transforming Text The text-transform property applies a specific text case to text as in all letters in UPPERCASE or all lowercase, or just initial Capital letters for each word text-tranform: capitalize uppercase lowercase none; text-transform: capitalize; First letter of each word will be uppercase Setting the Text s Small Caps Style The font-variant property applies SMALL CAPS style to text font-variant: small-caps normal; ul font-variant : capitalize; Aligning Text Horizontally The text-align property applies a specific alignmen to the text of a tag or other element The value justify means an even, not jagged, margin on both left and right sides of an element

50 HTML5 and CSS3 Design with CSS Page 9 51 51 52 52 53 53 54 54 55 55 text-align : left right center justify; text-align: center; Aligning Text Vertically The vertical-align property applies a specific vertical alignmen to the text relative to the content around it vertical-align : value baseline sub super top text-top middle bottom text-bottom initial; h2 vertical-align: 50%; Lowers the element by half of the line height Combining Font Formatting in a Single Style The font property applies setting several font values at once including style (italic), weight (boldface), variant (small-caps), size and line height, and typeface (fontfamily) font: font-style font-variant font-weight font-size[/line-height] font-family1 [, font-family2 ]; font: oblique small-caps lighter 16pt/1.5 Verdana; Try Selecting It OutList Style Types Page 1 The list-style-type property that applies a bullet or number style to unordered and ordered lists Styles include a disk (filled-in circle), circle (open circle), square, decimal numbers (with or without leading zeros), Roman numerals in upper or lower case, and upper or lowercase letters in English or Greek list-style-type: disk circle square decimal decimal-leading-zero lower-roman upper-roman lower-alpha upper-alpha lower-greek upper-greek none; Selecting List Style Types Page 2 Examples: ul list-style-type: square; ol list-style-type: lower-roman; 56 56 57

56 HTML5 and CSS3 Design with CSS Page 10 56 57 57 56 56 57 57 58 58 59 58 59 58 59 59 60 60 60 60 61 61 61 61 62 62 63 63 62 62 63 63 64 list-style-type: lower-roman; Try Images It Out for List Markers The list-style-image property that applies an image file as the bullet for unordered and ordered lists list-style-image: url(path/filename) none; ul list-style-image: url(bullet.gif); Try Pseudo-Classes Page It Out 1 A pseudo-class is the classification of an element based dynamically upon its current position selector:pseudo-class styles a:hover Pseudo-Classes Page 2 There are four special pseudo-classes that are often applied to hyperlinks as follows-- Links that have not yet visited or clicked: a:link property: value [; ] Links that have previously been visited: a:visited property: value [; ] Links that have been clicked: a:active property: value [; ] The mouse is pointing to it (hovering over the hyperlink) a:hover property: value [; ] The element has received keyboard or mouse focus a:focus property: value [; ] Pseudo-Classes Page 3 The hover, active and focus pseudo-classes also can apply to non-hypertext elements nav ul li:hover background- Try Structural It Out Pseudo-Class Page 1 Items may be classified based on their locations using structural pseudo-classes including: first-0f-type first element that matches specified type last-of-type last element that matches specified type nth-of-type n th element of specified type nth-last-of-type n th from last element of specified type only-of-type only element that matches specified type 64

HTML5 and CSS3 Design with CSS Page 11 64 64 65 65 66 66 67 67 68 only-of-type only element that matches specified type Structural Pseudo-Class Page 2 selector:structural-pseudo-class styles nav ul li:first-of-type Try Pseudo-Elements Page It Out 1 A pseudo-element is used to apply a style to a specified part of an element including: The first letter or line of an element Content to be inserted before or after an element Format (CSS3): selector::pseudo-element styles The pseudo-element may be first-letter, first-line, before or after Format (prior to CSS3): selector > pseudo-element styles Advisable still to this format for backward compatibility with older browsers Pseudo-Elements Page 2 Examples: section > p:first-letter font-size: 200%; section > p:first-line text-transform: uppercase; Try It Out 68