Introduction To Web Interaction Design
Introduction To Web Interaction Design
Interaction Design
With HTML and CSS
Introduction to Web
Interaction Design
With HTML and CSS
Michael Macaulay
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2018 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business
No claim to original U.S. Government works
Printed on acid-free paper
Version Date: 20170407
International Standard Book Number-13: 978-1-1389-1185-7 (Paperback)
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable
data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use.
The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to
copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write
and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any
electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any
information storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.copyright.com/) or
contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit
organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the
CCC, a separate system of payment has been arranged.
Trademark Notice: Registered trademark of products or corporate names are used only for explanation and identification without intent to
infringe.
Preface
Author
1. The Internet and the Web
1.1 Introduction
1.2 Learning Outcomes
1.3 Fundamentals of the Internet and the Web
1.4 How the Web Works
1.5 Requirements for Creating Websites
1.6 Useful Info
1.6.1 Web Links
1.6.2 Free Software
Part I HTML
2. Introduction to HTML
2.1 Introduction
2.2 Learning Outcomes
2.3 About HTML
2.3.1 The Structure of an HTML Document
2.3.1.1 The Contents of the Head Section
2.3.1.2 The Contents of the Body Section
2.3.2 Creating a Web Page
2.3.2.1 Creating a Web Page with a Text Editor
2.4 Useful Info
2.4.1 Web Links
3. Text
3.1 Introduction
3.2 Learning Outcomes
3.3 Headings
3.3.1 Headings in Design
3.4 Paragraphs
3.4.1 Paragraphs in Design
3.5 Line Breaks, Thematic Breaks, and Comments
3.5.1 Specifying Word-Break Opportunities
3.6 Superscript and Subscript
3.7 Importance, Emphasis, and Relevance
3.8 Quotations and Citations
3.9 Definitions and Abbreviations
3.10 Small Text
3.11 Text Edit
3.12 Displaying Computer Code and Output
3.13 Displaying Preformatted Text
3.14 Authors’ Details and Publication Dates
3.15 Providing Hidden Additional Information
3.16 Displaying a Dialog Box
3.17 Menu Bar and Drop-Down Menus
3.18 Displaying Special Characters
3.18.1Non-Breaking Spaces
3.19 Language Information and Text Directionality
3.19.1lang
3.19.1.1Benefits of Using the lang Attribute
3.19.2dir
3.20 Ruby Text
3.20.1<ruby>, <rb>, <rt>, and <rp>
3.20.2<rbc> and <rtc>
3.21 Acquiring Text for Use
3.22 Useful Info
3.22.1Web Links
4. Lists, Tables, and Links
4.1 Introduction
4.2 Learning Outcomes
4.3 Lists
4.3.1 Common List Attributes
4.3.2 Nested Lists
4.4 Tables
4.4.1 Basic Tables
4.4.1.1 <table>, <caption>, <th>, <tr>, and <td>
4.4.1.2 Columns’ Grouping
4.4.2 Table Cells’ Merging
4.4.2.1 <rowspan> and <colspan>
4.4.3 Long Tables
4.4.3.1 <thead>, <tbody>, and <tfoot>
4.4.4 Tables and Accessibility
4.4.4.1 The scope Attribute and Accessibility
4.4.4.2 The id and headers Attributes and Accessibility
4.5 Links
4.5.1 Linking to Another Website
4.5.2 Linking to Another Page on the Same Website
4.5.3 Linking to Another Part on the Same Page
4.5.3.1 Using the id Attribute
4.5.3.2 Using the name Attribute
4.5.3.3 Within-Page Links in Web Design
4.5.4 Linking to a Specific Part on Another Page
4.5.5 Linking to an E-Mail Program
4.6 Useful Info
4.6.1 Web Links
5. Forms
5.1 Introduction
5.2 Learning Outcomes
5.3 Form Element
5.4 Form Controls
5.4.1 <input>
5.4.1.1 Input Types for Collecting Text
5.4.1.2 Input Types for Offering Options
5.4.1.3 Input Types for Starting an Action
5.4.2 Multipurpose Button
5.4.2.1 <button>...</button>
5.4.3 Multiple Lines Text Input
5.4.3.1 <textarea>...</textarea>
5.4.4 Drop-Down List
5.4.4.1 <select>...</select>
5.4.4.2 <datalist>...</datalist>
5.4.5 Showing Task Progress
5.4.5.1 <progress>...</progress>
5.4.6 Displaying Measurement
5.4.6.1 <meter>...</meter>
5.4.7 Outputting Calculation Result
5.4.7.1 <output>...<output>
5.4.8 Labeling Form Controls
5.4.8.1 <label>...<label>
5.4.8.2 Labeling and Accessibility
5.4.9 Grouping Form Controls
5.4.9.1 <fieldset>...</fieldset>/<legend>...</legend>
5.4.10An Example Form
5.5 Form Design Guidelines
5.6 Useful Info
5.6.1 Web Links
6. Images
6.1 Introduction
6.2 Learning Outcomes
6.3 Adding Images with HTML
6.3.1 <img>, <source>, and <picture>
6.3.1.1 Specifying a Single Image Source
6.3.1.2 Making an Image a Link, and Linking to an Image
6.3.1.3 Containing and Captioning Images Properly
6.3.1.4 Specifying Multiple Image Sources
6.3.2 <canvas>...</canvas>
6.3.3 <svg>...</svg>
6.3.4 <map>...</map> and <area>...</area>
6.4 Document Embedding
6.4.1 <iframe>...</iframe>
6.5 Types of Images
6.5.1 Bitmapped Images
6.5.1.1 Image Resolution
6.5.1.2 Pixels per Unit Length
6.5.1.3 Color Depth
6.5.2 Vector Images
6.5.3 Image File Formats and Image File Size
6.5.5 Calculating File Size Generated from Scanned Documents
6.5.5 Calculating File Size Generated from Digital Camera
6.5.6 Calculating File Transmission Time
6.6 Guidelines for Effective Use of Images
6.6.1 Decorative Images
6.6.2 Large Images
6.6.3 Images with Text
6.6.4 Images and Captions
6.7 Acquiring Images for Use
6.7.1 Stock Images
6.7.2 Graphics Editors
6.7.3 Photography
6.7.4 Image Scanning
6.7.5 Web Coding Languages
6.8 Useful Info
6.8.1 Web Links
6.8.2 Free Software
7. Audio, Video, and Animation
7.1 Introduction
7.2 Learning Outcomes
7.3 Delivering Dynamic Media
7.4 Audio
7.4.1 Linking to Audio
7.4.2 Embedding Audio
7.4.2.1 <audio>.. .<audio>
7.4.2.2 <embed>
7.4.2.3 <object>.. .</object>
7.4.3 Audio in Web Design
7.4.3.1 Audio File Formats and Audio File Size
7.4.3.2 Guidelines on Effective Use of Sound
7.4.4 Acquiring Audio for Web Design
7.4.4.1 Stock Audio
7.4.4.2 Ripping Tracks from Discs
7.4.4.3 Digitizing Tracks from Vinyl Records
7.4.4.4 Creating Audio from Scratch
7.5 Video
7.5.1 Adding Video via Hosted Video Services
7.5.2 Adding Video to Web Page
7.5.2.1 Linking to Video
7.5.2.2 Embedding Video
7.5.3 Video in Design
7.5.3.1 Video File Size
7.5.3.2 Video File Formats and Codecs
7.5.3.3 Guidelines on Effective Use of Video
7.5.4 Acquiring Video for Design
7.5.4.1 Stock Videos
7.5.4.2 Ripping Video from DVD Video/Blu-Ray Disc
7.5.4.3 Video from Video Devices
7.5.4.4 Producing Video from Scratch
7.5.4.5 Video Screen Capture
7.6 Animation
7.6.1 Animation in Design
7.6.1.1 Guidelines on Effective Use of Animation
7.6.2 Acquiring 2D Animation for Design
7.6.2.1 Stock 2D Animation
7.6.2.2 2D Animation Programs
7.6.2.3 Coding
7.7 Useful Info
7.7.1 Web Links
7.7.2 Free Software
Part II CSS
8. Introduction to CSS
8.1 Introduction
8.2 Learning Outcomes
8.3 Introduction to CSS
8.3.1 Anatomy of CSS Rules
8.3.1.1 CSS Selector Types
8.3.1.2 Pseudo-Elements
8.3.1.3 Pseudo-Classes
8.3.1.4 nth Selectors
8.3.2 CSS Cascading Properties
8.3.2.1 Last Rule Principle
8.3.2.2 Specificity Principle
8.3.2.3 Inheritance
8.3.3 Methods of Specifying CSS Rules
8.3.3.1 Inline CSS
8.3.3.2 External CSS
8.4 Useful Info
8.4.1 Web Links
9. Color
9.1 Introduction
9.2 Learning Outcomes
9.3 Specifying Color in CSS
9.3.1 RGB Values
9.3.2 HSL Values
9.3.3 Foreground and Background Color
9.3.3.1 Color Transparency
9.4 Anatomy of Color and Color Models
9.4.1 Determining Color Values
9.5 Color in Design
9.5.1 Choosing Color Combinations
9.5.1.1 Monochromatic
9.5.1.2 Analogous
9.5.1.3 Complementary
9.5.1.4 Split Complementary
9.5.1.5 Double Contrast
9.5.1.6 Triadic
9.5.2 Color Proportions
9.5.3 Color in Content Organization
9.5.4 Color and Aesthetics
9.5.5 Color and Physiological Considerations
9.5.6 Color and Psychological Considerations
9.5.7 Color Preferences
9.5.8 Color and Accessibility
9.6 Useful Info
9.6.1 Web Links
10. Boxes: Size and Border
10.1 Introduction
10.2 Learning Outcomes
10.3 Box Dimensions
10.3.1width and height
10.3.1.1Specifying Logical Width and Height
10.3.2min-width and min-height and max-width and max-height
10.3.2.1Handling Content Overflow
10.3.2.2Specifying Minimum and Maximum Logical Width and Height
10.3.3calc()
10.4 Border, Padding, and Margin
10.4.1Border
10.4.1.1border-style
10.4.1.2border-width
10.4.1.3border-color
10.4.1.4border-top and border-bottom and border-right and border-left
10.4.1.5border
10.4.1.6border-image
10.4.1.7border-radius
10.4.2padding
10.4.2.1Specifying Padding for Logical Edges
10.4.3margin
10.4.3.1Specifying Margin for Logical Edges
10.4.3.2Margins in Design
10.5 Controlling Box Sizes
10.5.1Specifying How Boxes Are Rendered
10.5.2Making Boxes Resizable
10.6 Adding Shadows to a Box
10.7 Applying Outline to an Element
10.7.1outline-offset
10.8 Changing between Inline and Block Elements
10.9 Hiding Content
10.9.1Hiding Content by Using the display Property
10.9.2Hiding Content by Using the visibility Property
10.10Useful Info
10.10.1Web Links
11. Boxes: Transform and 3D
11.1 Introduction
11.2 Learning Outcomes
11.3 Transforming Elements
11.3.1 transform-origin
11.3.2 transform
11.3.2.1Applying Rotation and Skewing
11.3.2.2Applying Perspective
11.3.3 perspective
11.3.3.1Example Application of the perspective Property
11.3.4 transform-style
11.3.5 backface-visibility
11.3.5.1Full Explanation of the Cube Example
11.4 Useful Info
11.4.1 Web Links
12. Positioning Elements
12.1 Introduction
12.2 Learning Outcomes
12.3 CSS Positioning Methods
12.3.1Static Positioning
12.3.2Relative Positioning
12.3.2.1Specifying Offset for Logical Edges
12.3.3Absolute Positioning
12.3.4Fixed Positioning
12.3.4.1An Application of Fixed Positioning
12.3.5Sticky Positioning
12.3.5.1Sticky Global Navigation
12.3.6Using Element Positioning in Drop-Down Menus
12.3.6.1Drop-Down Menu Using List Elements
12.3.6.2Drop-Down Menu Using the <button> Element
12.3.7Ordering Overlapping Elements
12.3.8Floating Elements
12.3.9Clearing Obstructed Floated Elements
12.3.9.1A Common Problem with Non-Floated Parent Elements
12.3.9.2Multi-Column Content with Floats
12.4 Multi-Column Layout
12.4.1columns and column-span
12.4.2column-count, column-rule, and column-gap
12.4.3column-fill
12.5 Useful Info
12.5.1Web Links
13. Text: Typefaces and Fonts
13.1 Introduction
13.2 Learning Outcomes
13.3 Anatomy of Type
13.4 Typefaces and Fonts
13.4.1font-family
13.4.2@font-face
13.4.2.1Providing Broad Browser Support
13.4.3Fonts in Design
13.4.3.1Typeface Classifications
13.4.3.2Choosing a Typeface
13.5 Size of Text
13.5.1font-size
13.5.2font-size-adjust
13.5.3Font Size in Design
13.5.3.1Font Size and Typeface
13.5.3.2Font Size, Operating Systems, Resolution, and Screen Size
13.5.3.3Type Size and Target Audience
13.5.3.4Type Size and Visual Hierarchy
13.6 Weight of Text
13.6.1font-weight
13.6.2Font Weight in Design
13.7 Text Style
13.8 Useful Specialized Font Properties
13.8.1font-feature-settings
13.8.2font-synthesis
13.8.3font-variant
13.8.4font-stretch
13.9 Specifying Multiple Font Properties
13.10Useful Info
13.10.1Web Links
14. Text: Formatting and Decoration
14.1 Introduction
14.2 Learning Outcomes
14.3 Content Alignment
14.3.1text-align
14.3.1.1Text Alignment in Design
14.3.2vertical-align
14.3.3Centering Blocks of Text
14.3.3.1Horizontal Centering
14.3.3.2Vertical Centering
14.3.3.3Vertical and Horizontal Centering
14.4 Text Indenting and Outdenting
14.5 Text Spacing
14.5.1letter-spacing, font-kerning, and word-spacing
14.5.2text-rendering
14.5.3Text Spacing in Design
14.6 Line Spacing
14.6.1line-height
14.6.2Line Height in Design
14.7 Specifying Lowercase or Uppercase
14.7.1Text Capitalization in Design
14.8 Specifying Content Directionality
14.8.1direction
14.8.2writing-mode
14.8.3text-orientation
14.8.4text-combine-upright
14.9 Text Decoration
14.9.1text-decoration
14.9.2text-decoration-skip
14.9.3text-underline-position
14.9.4text-emphasis
14.9.5text-shadow
14.10Styling with Pseudo-Elements
14.10.1::first-letter, ::first-line, ::before, ::after, ::selection
14.10.2Using content Property Values
14.11Styling Text with Pseudo-Classes
14.11.1Styling Links
14.11.2:target
14.11.2.1Lightbox Display and the :target Pseudo-Class
14.11.3:not(X)
14.11.4:empty
14.12Ruby Properties
14.12.1Ruby Properties for Styling and Formatting
14.12.1.1ruby-position
14.12.1.2ruby-align
14.12.1.3ruby-merge
14.12.2Converting Elements to Ruby Elements
14.13Useful Info
14.13.1Web Links
15. Images: Content and Background Images
15.1 Introduction
15.2 Learning Outcomes
15.3 Sizing Images
15.3.1Specifying the Quality of Resized Images
15.3.2Specifying Size for Responsive Images
15.4 Clipping Images
15.5 Aligning Images
15.6 Positioning and Fitting Images in Element’s Box
15.6.1object-position
15.6.2object-fit
15.7 Background Images
15.7.1Adding Background Images
15.7.2Repeating Background Images
15.7.2.1repeat-x and repeat-y
15.7.2.2space and round
15.8 Specifying Background Image Position Area
15.9 Clipping Background Images
15.10Sizing Background Images
15.10.1background-size with Keywords
15.11Multiple Background Images
15.12Fixing the Position of Background Images
15.13Positioning Background Images
15.14Shorthand Background Property
15.14.1Multiple Background Images with background Property
15.15Useful Info
15.15.1Web Links
16. Images: Effects
16.1 Introduction
16.2 Learning Outcomes
16.3 Image Sprites
16.3.1Using Image Sprites with the <input> Element
16.4 Gradients
16.4.1Linear Gradients
16.4.1.1Repeating Linear Gradients
16.4.2Radial Gradients
16.4.2.1Example Application of Radial Gradient
16.4.2.2Repeating Radial Gradient
16.5 Filters
16.6 Blending Images
16.6.1background-blend-mode
16.6.2mix-blend-mode
16.6.3isolation
16.7 Useful Info
16.7.1Web Links
17. Lists, Tables, and Forms
17.1 Introduction
17.2 Learning Outcomes
17.3 Lists
17.3.1list-style-type
17.3.2list-style-image
17.3.3list-style-position
17.3.4list-style
17.3.5Styling Lists with Generic Properties
17.3.5.1Styling <ol> and <ul> Elements with Generic Properties
17.3.5.2Styling Definition Lists
17.3.6Converting Other Elements to list-items
17.4 Tables
17.4.1Styling Tables with Generic Properties
17.4.2Styling with Table-Specific Properties
17.4.2.1border-collapse
17.4.2.2border-spacing
17.4.2.3empty-cells
17.4.2.4table-layout
17.4.3Converting Other Elements to Table Elements
17.4.4Guidelines for Designing Effective Tables
17.5 Forms
17.5.1Images in Input Fields
17.5.2Styling Form Elements
17.5.2.1Styling Form Buttons
17.5.2.2Styling Default Button
17.5.3Specifying Cursor Shape
17.5.4Validating Form Inputs
17.5.4.1:in-range and :out-of-range
17.5.4.2:valid and :invalid
17.6 Useful Info
17.6.1Web Links
18. Animation
18.1 Introduction
18.2 Learning Outcomes
18.3 About Animation
18.4 CSS 2D Animation
18.4.1@keyframes
18.4.2Animation Properties
18.4.3Using @keyframes and Animation Properties
18.4.3.1Applying Multiple Animations to an Element
18.4.3.2Animated CSS Lightbox Display
18.4.4CSS Transitions
18.5 3D Animation
18.5.1CSS 3D Animation
18.5.1.1An Example Application of 3D Animation
18.6 Animation in Design
18.6.1Animation in Attracting Attention
18.6.2Animation in Providing Feedback
18.6.2.1Depiction of Transition
18.6.2.2Rollover Effect
18.6.3Animation in Providing Explanation
18.6.4Animation in Providing Entertainment
18.6.5Animation in Setting Mood
18.6.6Animation in Providing a Sequence of Items
18.7 Beyond CSS-Only Animation
18.8 Useful Info
18.8.1Web Links
19. Layout with Flexible Box
19.1 Introduction
19.2 Learning Outcomes
19.3 Anatomy of Flexible Box Layout
19.4 Controlling Flow Direction of Flex Items
19.5 Controlling the Wrapping of Flex Lines
19.6 Specifying Flex Direction and Wrapping Together
19.7 Controlling the Size of Flex Items
19.7.1Specifying Flex Items Sizing Factors Individually
19.7.2Specifying All Flex Items Sizing Factors with One Property
19.7.2.1Vertical Space Example
19.8 Aligning Flex Items
19.8.1Aligning All Flex Items in a Flex Container
19.8.1.1justify-content
19.8.1.2align-content
19.8.1.3align-items
19.8.2Aligning Flex Items Individually
19.9 Ordering Flex Items
19.10Useful Info
19.10.1Web Links
20. Layout with the Grid Model
20.1 Introduction
20.2 Learning Outcomes
20.3 About Layout Grids
20.4 Anatomy of the Grid Layout Model
20.5 Properties for Creating Grid Layout
20.5.1Specifying Grid Columns, Rows, and Areas
20.5.1.1grid-template-columns and grid-template-rows
20.5.1.2Specifying Multiple Names for a Grid Line
20.5.1.3Handling Repeating Values
20.5.1.4grid-template-areas
20.5.1.5grid-template
20.5.2Controlling Implicit Tracks and Items’ Auto-Placement
20.5.2.1grid-auto-columns and grid-auto-rows
20.5.2.2grid-auto-flow
20.5.3Specifying Gutters between Grid Columns and Rows
20.5.3.1grid-column-gap, grid-row-gap, and grid-gap
20.5.4Specifying All Grid Structure Properties Together
20.5.4.1grid
20.5.5Specifying Grid Item Placement within the Grid
20.5.5.1Specifying Grid-Placement Values Separately
20.5.5.2Specifying Column and Row Grid-Placement Values Separately
20.5.5.3Specifying All Grid-Placement Values Together
20.6 Aligning Grid and Grid Items
20.6.1Aligning All Grid Items in a Grid Container
20.6.1.1justify-content and align-content
20.6.1.2justify-items and align-items
20.6.2Aligning Grid Items Individually
20.6.2.1justify-self and align-self
20.7 Ordering Grid Items
20.7.1Ordering Grid Items Display Sequence
20.7.1.1order
20.7.2Specifying Layer Positions for Stacked Grid Items
20.7.2.1z-index
20.8 Example Application of Grid
20.9 Useful Info
20.9.1Web Links
21. Responsive and Adaptive Web Design
21.1 Introduction
21.2 Learning Outcomes
21.3 Screen Size and Resolution Issues
21.4 Fixed and Liquid Layouts
21.4.1Fixed Layouts
21.4.2Liquid Layouts
21.5 Responsive vs. Adaptive Design
21.6 Creating Responsive Design
21.6.1Steps for Creating a Responsive Design
21.6.1.1Creating the Layouts for Different Screen Sizes
21.6.1.2Creating Fluid Media Assets
21.6.1.3Creating CSS Rules for Changing between Layouts
21.6.2Implementing Responsive Design via Flexbox
21.6.3Implementing Responsive Design via Grid
21.7 Creating Adaptive Design
21.8 Useful Info
21.8.1Web Links
22. Beyond HTML and CSS
22.1 Introduction
22.2 Learning Outcomes
22.3 Enhanced CSS
22.4 Using Scripting Languages with HTML
22.4.1Client-Side Scripting
22.4.1.1Embedding Client-Side Scripts
22.4.1.2External Client-Side Scripts
22.4.2Server-Side Scripting
22.4.2.1Using Server-Side Script with AJAX
22.4.2.2Server-Side Script, AJAX, and Database
22.4.2.3Storing Data in Database
22.4.2.4Retrieving Data from Database
22.5 Optimizing Website Performance
22.5.1Optimizing Text-Based Assets
22.5.2Optimizing Image-Based Assets
22.5.3Optimizing Web Font
22.6 Useful Info
22.6.1Web Links
Part III Web Design Principles and Practices
23. Design: The Fundamentals
23.1 Introduction
23.2 Learning Outcomes
23.3 Visual Aesthetics in Design
23.4 Design Elements and Principles
23.4.1Basic Elements of Design
23.4.1.1Point
23.4.1.2Line
23.4.1.3Shapes
23.4.1.4Size/Scale
23.4.1.5Space
23.4.1.6Hue and Value
23.4.1.7Texture
23.4.2Principles of Design
23.4.2.1Balance
23.4.2.2Emphasis
23.4.2.3Rhythm
23.4.2.4Proportion
23.4.2.5Unity
23.5 Useful Info
23.5.1Web Links
24. Designing for the Web
24.1 Introduction
24.2 Learning Outcomes
24.3 User Experience
24.4 Website Credibility
24.4.1Show Usefulness
24.4.2Show Professionalism
24.4.3Manage Adverts Properly
24.4.4Show Trustworthiness
24.5 Designing Website Interfaces
24.5.1Designing Website Navigation
24.5.1.1Tabs Metaphor
24.5.1.2Drop-Down Menus
24.5.1.3Site Map
24.5.1.4Footers
24.5.2Designing Content Area
24.5.2.1Homepage Content
24.5.2.2Content Display Size
24.5.2.3Content Length
24.5.2.4Line Length
24.5.2.5Content Layout
24.5.2.6Managing Content Amount
24.5.2.7Writing Content for the Web
24.6 Designing for Different Ages
24.7 Useful Info
24.7.1Web Links
25. Designing for Mobile Devices
25.1 Introduction
25.2 Learning Outcomes
25.3 Designing for Smartphones
25.3.1Designing Content for Smartphones
25.3.1.1Content Structuring
25.3.1.2Number of Columns
25.3.1.3Amount of Text Entry
25.3.1.4Registration
25.3.2Designing Navigation for Smartphones
25.3.2.1Designing Touch Targets
25.3.2.2Designing Touch Gestures and Animations
25.4 Designing for Tablets
25.5 Useful Info
25.5.1Web Links
Part IV Web Development Process
26. Web Development Process
26.1 Introduction
26.2 Learning Outcomes
26.3 User-Centered Design Process
26.3.1Task Analysis Phase
26.3.1.1Field Studies
26.3.1.2Hierarchical Task Analysis
26.3.2Requirements-Gathering Phase
26.3.3Design Phase
26.3.3.1Card Sorting
26.3.3.2Prototypes
26.3.4Evaluation Phase
26.3.4.1Usability Testing
26.3.4.2Evaluating Websites for Accessibility
26.3.4.3Evaluating Your Website for SEO
26.3.4.4Data Collection for Evaluation
26.3.4.5Observational Techniques
26.3.4.6Delivering an Application on the Web
26.4 Useful Info
26.4.1Web Links
27. Managing Web Development
27.1 Introduction
27.2 Learning Outcomes
27.3 Introduction to Web Development Management
27.3.1Web Project Management Tools
27.3.1.1Brainstorming
27.3.1.2Work Breakdown Structure
27.3.1.3Critical Path Method
27.3.1.4Gantt Chart
27.4 Web Project Management Phases
27.4.1Initiation Phase
27.4.1.1Project Definition Process
27.4.1.2Proposal Process
27.4.1.3Contract Process
27.4.2Preproduction Phase
27.4.2.1Project Team Selection
27.4.2.2Content Gathering and Clearance Process
27.4.2.3Website Design Process
27.4.2.4Media Objects Design Process
27.4.2.5Media Production Tools Selection
27.4.3Production Phase
27.4.4Postproduction Phase
27.4.4.1Final Evaluation
27.4.4.2Delivery and Final Sign-Off
27.4.4.3Closure
27.5 Useful Info
27.5.1Web Links
27.5.2Free Software
28. Introduction to Intellectual Property
28.1 Introduction
28.2 Learning Outcomes
28.3 Intellectual Property
28.3.1Copyright
28.3.1.1When Copyright Protection Begins
28.3.1.2Duration of Copyright
28.3.1.3Rights Protected by Copyright Laws
28.3.1.4Limitations on Rights
28.3.1.5Related Rights
28.3.2Industrial Property
28.3.2.1Patents
28.3.2.2Industrial Designs
28.3.2.3Trademarks
28.3.3Seeking Permission to Use People’s Works
28.3.4Dealing with an Infringement
28.4 Intellectual Property in Web Design
28.4.1Rights in Text
28.4.2Rights in Images and Photographs
28.4.3Rights in Music and Speech
28.4.4Rights in Video and Animation
28.4.5Rights in Codes and Database
28.5 Industrial Property in Web Design
28.6 Useful Info
28.6.1Web Links
Bibliography
Index
Preface
Target Audience
This book is intended for:
Those with no prior knowledge of Web design who wish to learn how to design and build
websites of professional quality.
Someone who already knows how to design and build a website using Web tools, such as content
management systems, e-commerce platforms, or blogging software, that allow him or her to build
websites without the knowledge of coding, but wants more control over the design offered.
Part I: HTML
This part presents chapters that introduce the functionalities supported by HTML. It shows how to use
them to add various elements to a page, including text, links, lists, tables, forms, images, audio, video, and
animation. It also shows how to use them to structure the content of a Web page, such as into headings,
sections, paragraphs, and quotations.
Michael Macaulay, PhD, is a freelance educator, developer, and user-experience designer and evaluator.
Formerly, he was a senior lecturer and course director for multimedia courses at London South Bank
University, United Kingdom. He earned his PhD in 2000 in the effects of human–computer interaction and
multimedia in learning from Loughborough University, United Kingdom. In the past, he had also been a
computer systems administrator, computer systems programmer and analyst, and desktop publisher.
1
The Internet and the Web
1.1 Introduction
It is useful to know a little about the technical aspects of the Internet and the Web in order to better
understand the various terminologies used in this book and also how what you produce will generally
work. If you find that something is too technical in this chapter, you can skip it and then come back to it
when you feel more comfortable with the subject or feel the need to know it.
The files on Web servers are usually accessed using a Web browser (technically known as Web
client). Popular Web browsers include Internet Explorer, Microsoft Edge, Firefox, Chrome, Safari, and
Opera. Technologies, such as Web browsers, that render files into Web pages in one form or another are
generally referred to as user agents. For each file or document (i.e., resource) on a Web server, there is
a unique address, known as Uniform Resource Locator (URL) or Web address, which describes its
location. You may also come across the terms URI and URN. The relationship between these terms is
clarified further shortly in the NOTE box. The format of a URL is as follows:
URL = protocol + IP address of server + location of file on server
The syntax is: protocol://host.domain [:port]/path/filename
Therefore, the URL for a file situated on a Web server on the Internet might be written as shown in
Figure 1.2.
In the example, the name of the file is “bolts.html.” It is located in the “bits” folder (or directory),
which itself is in the “products” folder on a server called “example.com,” which is a WWW server (i.e.,
a Web server). HyperText Transfer Protocol (HTTP) is the protocol used by the Web for data
communication, and 80 is the port that the browser typically uses to establish connection with a Web
server, and assumed, so it is normally omitted when an address is specified. In order to access a file on a
Web server, a user would typically enter the Web address in a Web browser, click a link to it on a Web
page that is already opened, or choose it from the bookmark, which is a list of previously stored visited
Web addresses.
How the browser delivers a requested file depends on the type of file. If it is a Web page, it is
automatically displayed as a Web page, but if it is another type of file, such as a Word document, you may
be given various other options, such as the option to save or open it. For files that are not Web pages, the
browser may use other types of software, which are categorized as plug-ins and helper applications. A
plug-in is embedded within a Web page, while a helper application is separate from the browser and
operates independently of it, once the browser initiates it. Different types of files require different types
of plug-ins or helper applications.
Although the Web is still most commonly accessed via desktop and laptop computers as of time of
writing, it is increasingly accessed via a wide range of mobile devices, such as tablets and mobile
phones, the capabilities and screen sizes of which vary widely. In addition, the Web is accessed by a
wide range of people, including those with disabilities. The implication of this is that in order to reach as
many people as possible, a website needs to be created in a way that allows viewing on a variety of
devices and supports assistive technologies, which are the technologies that people with disabilities use
to access Web pages. A common example is the screen reader, used by blind and visually impaired
people to read out the contents of a Web page. Indeed, in many countries, some types of websites are
required by law to be accessible to those with disabilities.
FIGURE 1.3 An illustration of what happens when a user requests a Web page.
2.1 Introduction
HyperText Markup Language (HTML) is the standard markup language for creating Web pages. Although,
the knowledge of HTML is, in theory, not necessary to create Web pages, because there are tools that
allow you to do this without having to write any code, knowing HTML enables you to customize or refine
outputs from these tools, where necessary. Naturally, to be a serious Web designer, the knowledge of
HTML could be considered a mandatory skill.
Some attributes can only be used with some elements, while some are global attributes, which means
that they can be used with any element. Commonly used global attributes include title, id, and class. These
attributes are used in various examples given in this book. The title attribute is used to provide extra
information about an element. If the element is displayed, then the value of the attribute is usually
displayed when the cursor is over the element. The id attribute is used to give an identity that is unique in
a document to an element, and class is used to identify a group of elements as being different from others,
using a name. The same class name may be assigned to multiple elements, and vice versa. Where an
element belongs to multiple classes, the class names are space-separated. For instance, in Figure 2.2,
if the element that belongs to the “art” class also belongs to “modern” class, then the value of class
attribute will be “art modern.”
In addition to attributes that transform the contents of elements, there are others that represent the events
generated by various HTML elements, such as global events attributes (generated by any element),
window events attributes (generated by window objects), form events attributes (generated by form
elements), keyboard events attributes (generated by keyboard activities), mouse events attributes
(generated by mouse activities), and media events attributes (generated by media playback activities).
All of these attributes are used in conjunction with a scripting language, typically JavaScript, to produce
dynamic interaction with the user. Although HTML5 is not case-sensitive, it is good practice to always
use uppercase and lowercase consistently for better understanding of a code.
NOTE: Representation of HTML elements
When the functions of elements are formally introduced and defined, the formats <element
name>...</element name> (e.g., <p>...</p>) or <element name> (e.g., <base>) are used. The
former means that the element can contain content between the tags, while the latter means that it
is an empty element and cannot have content and can only take attributes.
TABLE 2.1
The Primary Elements for Structuring an HTML Document
Element Function
<!DOCTYPE html> Specifies that a document is an HTML document.
<html>...</html> Specifies the start and end of an HTML document.
<head>...</head> Specifies the start and end of the document header section.
<body>...</body> Specifies the start and end of the body of the document.
2.3.1.1 The of the Head Section
The HTML elements placed in the head section (i.e., in the <head> element) are meta-related elements, in
that they provide metadata (i.e., data that provide information about other data). More specifically, they
provide information about a document, including information about other documents that they need (if
relevant). The information is only for the browser and is not displayed in the browser window. These
elements typically include <title>, <meta>, <base>, <link>, <style>, and <script>. The <style> element is
used to embed CSS rules and discussed under CSS accordingly. The <script> element is used to embed or
link to an executable script, such as JavaScript, and is introduced in Chapter 22 where it is more relevant,
such as under Flash video in Chapters 7 and 22. The rest of the elements are discussed here.
2.3.1.1.1 <title>...</title>
The <title> element allows you to define the title of a Web page, which is displayed in the bar at the top
area of the browser. Figure 2.4 shows how to use it, and Figure 2.5 depicts the result. Title description is
one of the pieces of information used by search engines to index Web pages; therefore, making it reflect
closely the content of a page improves the chances of search engines ranking the page highly (i.e., placing
it as near to the top as possible of their search results). This ensures that the page can be found by those
looking for the type of information it provides. Ideally, it should be the same as the main heading for a
page. The practice of doing things to ensure high search engine ranking for a page is known as search
engine optimization (SEO), and more about it is discussed later under other page features used for
realizing it, such as page description, image description, headings, and link text. It is also discussed in
Chapter 21 in relation to how it is affected by how mobile-friendly a layout is and in Chapter 26 in
relation to its evaluation.
FIGURE 2.4 How elements are used in the <head> element and the result.
CHALLENGE 2.1
Visit a few websites, navigate through the pages, and see how closely their titles match the
headings and what the page is about.
2.3.1.1.2 <base>
The <base> element allows you to define the base URL (Uniform Resource Locator) for relative paths
specified in a document. URL, as explained in Chapter 1, is the description of the location of a resource
(e.g., document or media) on the Internet. Once a base URL is defined, any relative URL specified in the
body section of a document is appended to its end to describe the full URL. This saves having to specify
absolute paths (i.e., full paths) for all links. Only one base element may be used in a document, and it
must have either an href attribute, a target attribute, or both. In the example in Figure 2.6, the href attribute
defines the base URL, which means that the value of the src attribute in the <img> element (i.e., settee.jpg,
which is an image filename) is appended to its end to derive the full path,
“http://www.example.com/images/settee.jpg,” which is the location of settee.jpg. The <img> element is
used to display images and is discussed fully in Chapter 6. The value of the target attribute (i.e., _blank)
specifies that the image file should be displayed in a new browser window or tab.
Other possible values for the target attribute and their functions are listed in Table 2.2. These values
are sometimes called browsing context names or keywords. This is because they describe the
environment in which a document object is presented.
FIGURE 2.6 Example use of the <base> element and the href and target attributes.
TABLE 2.2
The Values for the target Attribute
Attribute’s Value Function
_blank Opens a linked document in a new window or tab.
_self Opens a linked document in the current window. This is default.
_parent Opens a linked document in the parent frame.
_top Opens a linked document in the top-level frame (i.e., whole window).
CHALLENGE 2.2
If in the example in Figure 2.6, the value of the href attribute is “http://www.example.com/” and the
“settee.jpg” file is still in the same location, how would you write the value of the src attribute?
2.3.1.1.3 <link>
The <link> element allows a document to be linked to resources external to it. Table 2.3 lists the
attributes that it supports, and Figure 2.7 shows how the element is used with the commonly used ones.
TABLE 2.3
Common Attributes Used with the <link> Element
FIGURE 2.7 example use of the <link> element and the rel and type attributes.
In the example, the linked resource is a document and “style.css” specifies its location and name. In this
case, the location is specified implicitly as a relative address (i.e., relative to the location of the current
document). It essentially says that the “style.css” file is in the same folder as the document that is linking
to it. The other type of address is an absolute address, in which full path is specified. The difference
between the two is explained in Figure 2.8.
FIGURE 2.8 Explanation of absolute and relative addressing
Back to the example in Figure 2.7, the relationship of “style.css” to the current document is specified as
“stylesheet,” and “text/css” says that its content is CSS code. More than one <link> element can be used
in a document, for example, for specifying multiple stylesheets. See “Methods of specifying CSS rules” in
Chapter 8.
CHALLENGE 2.3.
If an HTML file named “index.html” is located in a folder called “home” and a CSS file called
“main_styles.css” is located in a subfolder of the subfolder of the folder, write a <link> element
code to place in the head section of the HTML file that points to the CSS file.
2.3.1.1.4 <meta>
The <meta> element allows you to describe various kinds of information about a document that cannot be
described using other meta-related elements, such as <title>, <link>, and <base>. The kinds of
information it can be used to describe range from those used by search engines in ranking their search
results to those about the creator of a document and the technologies, such as software, used to create the
document. The element uses four attributes: name, http-equiv, content, and charset, which are combined in
different ways to describe different kinds of metadata. Table 2.4 lists the functions of these attributes and
the commonly used values.
While the charset attribute can be set alone, when either name or http-equiv is used, the content
attribute must also be used in a name-value pair fashion. Essentially, the property to be defined is
specified by the value of the name or http-equip attribute, and the value to give to the property is specified
by the value of the content attribute. When the http-equiv attribute is used, a <meta> element is known as a
pragma directive, which is an instruction to the compiler; a compiler is a computer language that
interprets one computer language into another. Figure 2.9 shows examples of the various ways you can
use the <meta> element and its attributes.
In the example, charset says that the character encoding used for the page is UTF-8. Character
encoding is the allocation of a unique code to a character, using a character set. The technique predates
computers, or the Internet and the Web, and goes back, for example, to the use of Morse code for
telegraphing messages. The first internationally accepted character-encoding system to be used in
computers was the American Standard Code for Information Interchange (ASCII) encoding standard,
which is adequate for encoding all the characters in English text. Because it was unsuitable for non--
English languages in its original form, various variants were later developed for different languages,
leading to compatibility problems. To streamline everything, Unicode, a multilingual character set, was
developed, and UTF-8 is one of the Unicode Transformation Format (UTF) standards for encoding the
characters. It is also currently the most commonly used standard for the Web. Alternatives include UTF-
16 and UTF-32. Knowing the character encoding used for a Web page enables the browser to correctly
display the textual content of the page. Figures 2.10 and 2.11 demonstrate this. The default character
encoding for HTML5 is UTF-8.
TABLE 2.4
Defined Attributes for the <meta> Element
Attribute Function Commonly Used Values
name Defines a property name. author (specifies creator of Web page), description (provides a 155-character maximum
description of a page that is useful for SEO), robots (specifies whether or not search engine
should index page), language (provides the natural language used), and keywords (defines
keywords for a page).
http-equiv Defines an HTTP header property that For example content-type (specifies MIME type), default-style (specifies the default
is used as an alternative to the stylesheet to use), refresh (specifies document refresh interval), pragma and cache-control
response header sent with an HTML (specify whether or not a page should be cached, and expires (specifies when a cached
document by the Web server. page should expire and a new version downloaded).
content Specifies the value associated with the Depends on the value of http-equiv or name attribute. See Figure 2.5.
http-equiv or name attribute.
charset Specifies character encoding. Character set (e.g., UTF-8).
FIGURE 2.9 How the attributes of the <meta> element are used.
Back to the example in Figure 2.9, the value, keywords, gives the words that people might use to find
the page; description says what the page is about and is used by search engines; author provides the name
of the page creator; the first robots says search engines should not add page to their search results and the
second robots says that it is all right to index page, but the pages to which the page is linked should not be
indexed; expires says that page should be removed from the browser’s cache at the specified date, which
must be in the format shown, although “0” could be used to specify now, meaning that the page will not be
cached at all and a new version is downloaded every time; pragma and cache-control say not to cache
page; and the first refresh says to reload the page after 15 seconds and the second refresh says to redirect
user to “http://www.newsite.com” after 3 seconds.
CHALLENGE 2.4
In what type of Web application do you think it would be necessary to refresh the page as frequently
as a few seconds and why?
FIGURE 2.12 Comparison between how page layout components might be defined.
TABLE 2.5
HTML5 Layout Elements and Their Functions
FIGURE 2.13 Example of how the html5 layout elements is used.
In Figure 2.14, notice how the rendered elements are not laid out. The only bit of structuring included is
with the <figure> element, which, by default, is displayed with default margins (space) around it. What
this shows is that in order to create a page layout, such as the one illustrated earlier in Figure 2.12, the
layout elements need to be positioned and styled accordingly. They need to be given, for example,
dimensions, border, and background color, all of which is done using CSS. Indeed, even though the
browser might recognize the HTML layout elements for what they are, without the text descriptions in the
example, it would have been impossible to know that they are there, since they are essentially containers.
CHALLENGE 2.5
Sketch the structure for the home page of your personal website on paper and then write the HTML
code to describe the structure, using HTML5 layout elements and indenting the code as appropriate
to make it easy to read.
CHALLENGE 2.6
Write an HTML code that does what the following statements describe:
This text is in a div element.
This text is in a span element inside a div element.
This text has no markup, but this part is in a span element.
CHALLENGE 2.7
Write an HTML code to create a content that is rendered the same way as below, using the elements
and attributes used in Figure 2.18:
Roses are red,
Violets are blue.
But these are not the only things that are red or blue.
CHALLENGE 2.8
Search the Web for a Web page that is not too complex, and open the source code for the page, as
described in the NOTE box above, and then, copy the code (e.g., via pressing Ctrl + A to select all
the code and Ctrl + C to copy). Then, paste and save the file with a .html extension. Next, open the
file in a browser. You will see that what is displayed does not look like the original page. This is
because the resources used by the page, such as CSS and images files, are not available on your
computer.
2.4 Useful Info
2.4.1 Web Links
HTML specifications: w3.org/TR/html51, w3.org/standards
Web development documents: webplatform.org
Accessibility: w3.org/WAI/tutorials, webaim.org
HTML5 support testing: html5test.com
HTML tutorials (Here are just a few free tutorial sites on HTML and other Web languages ):
w3.org/wiki, html5rocks.com, sitepoint.com, w3schools.com, codecademy.com, quackit.com,
developer.mozilla.org/en-US/docs/Web tutorialspoint.com, whatwg.org, htmlgoodies.com,
htmldog.com, htmlcodetutorial.com, echoecho.com, learn.shayhowe.com, html.net, tizag.com, html-5-
tutorial.com
3
Text
3.1 Introduction
Text is the most commonly used element to communicate on the Web, and one of the factors central to its
ability to communicate effectively is how well it is structured. This chapter presents the HTML elements
that can be used to accomplish this.
3.3 Headings
HTML provides six levels of headings, which are represented by <h1>, <h2>, <h3>, <h4>, <h5>, and
<h6> elements. The contents of the elements are displayed in different sizes and in bold. The content of
<h1> is displayed in the largest size and that of <h6> in the smallest size. <h1> is used for main headings,
<h2> for subheadings, <h3> for sub-subheadings, and so on. Although the displayed sizes may vary
between browsers, the relationship between them is still maintained. The default text size set by users can
also affect the displayed sizes of these elements. Figure 3.1 shows how the headings’ elements are used,
and Figure 3.2 depicts the rendered result.
FIGURE 3.1 Example usage of the headings elements.
CHALLENGE 3.1
Write the HTML code to implement the example hierarchical structure shown in Figure 3.3.
3.4 Paragraphs
Paragraphs are defined with the <p> element, which you have already seen in some examples in Chapter
2. To create a paragraph of text, the text is enclosed between the tags of the element. Since it is a block-
level element, its content is always placed on a new line by default. Some space is also placed between
it and the element directly above and below. Figures 3.5 and 3.6 illustrate how it is used and show its
effect.
CHALLENGE 3.2
As you may know, the <p> element, like the <div> element, is a block element, which means that
they both start on a new line. However, you should not use one in place of the other, because they
have different semantic meanings to user agents. To compare the visual differences between the two,
enter the following HTML code in a text editor and render it.
This text is followed by a paragraph element.
<p>This content is in a block element.</p>
This text is followed by a div element.
<div>This content too is in a block element.</div>
FIGURE 3.8 Line break, horizontal rule, and comment elements in use.
In contrast, the <!–...–> element does not affect or display anything and is only used to annotate HTML
code to make it easy to understand what different parts do. Adding comments to describe what various
parts of a code do is good practice for the benefits of both authors and others who might have to work
with the code at a later date, for example, for the purpose of maintenance. Figures 3.8 and 3.9 illustrate
how these three elements are used and show their effects.
CHALLENGE 3.3
Where would you insert line and theme breaks in the following and why?
“Orange is a fruit of the citrus species. It is a hybrid between pomelo and mandarin. It is very old.
For example, sweet oranges were mentioned in Chinese literature in 314 BC. Banana is an edible
fruit that is botanically classified as a berry and is produced by several kinds of large herbaceous
flowering plants. Plantains are a type of banana. The universe, according to Wikipedia, is all of time
and space and its contents. It includes planets, stars, galaxies, the content of intergalactic space, the
smallest sub-atomic particles, and all matter and energy.”
CHALLENGE 3.4
Write the HTML code to display the content below, at least the chemical equation:
The universe is about 91 billion (28 × 10 9 ) light-years wide and still expanding. Inside it, many
chemical reactions are going on all the time, some of which we understand and can represent with
equations. For example, the following chemical equation shows what happens when methane (CH
4 ) burns in oxygen (O 2 ): CH 4 + 2O 2 = CO 2 + 2H 2 O
FIGURE 3.14 Example usage of the strong, emphasis, and highlight elements.
CHALLENGE 3.5
For which of the following would you use <strong>, <em>, <b>, or <i> in a body of text?
The new name for a process.
The name of a body organ.
A word that forcefully instructs.
The name of a ship.
The English name for a rare plant.
The word “Warning!”
A phrase to which you want people to pay attention.
CHALLENGE 3.6
Why should you not use the <cite> element to make text italic type?
CHALLENGE 3.8
Why should you not reduce font size to achieve small text instead of using the <small> element?
3.11 Text Edit
Sometimes, it is useful to show both old and new content together in order to communicate some types of
messages more effectively. This is done, for example, when you want to show people what the previous
information was, whether for comparison (as in when showing price cuts in sales) or cross-checking (as
in when people might be looking for the old information). The elements used to do this are <ins>, <del>,
and <s>. Table 3.2 shows the functions of the elements. Figure 3.24 shows their usage, and Figure 3.25
depicts the result.
TABLE 3.2
Insert, Delete, and Strikethrough Elements
Element Function
<ins>...</ins> Inserts a span of text and underlines it. Again, the <u> element should not be used for this, as it is obsolete.
<del>...</del> Deletes a span of text, which is usually indicated with strikethrough text.
<s>...</s> Renders text with a line through it (i.e., strikethrough text).
FIGURE 3.24 Example usage of the insert, delete, and strikethrough elements.
It is useful to note that even though both the <del> and <s> elements draw a line through their text
content, user agents interpret each according to its meaning. A screen reader, for example, will say which
it is, so that a blind user can understand.
CHALLENGE 3.9
Write the HTML code to produce the following:
FIGURE 3.26 The code, sample, and keyboard input elements in use.
CHALLENGE 3.10
Which of the following elements would you use to present the sequence required to perform a
word-processing task: <code>, <kbd>, or <samp>?
Notice in the example that the content of the <pre> element is as it is in the HTML source. Also, notice
that the element is inside the <p> element. However, it does not have to be; the text above and below it
can be in separate <p> elements. Moreover, note that even though the <code>, <kbd>, and <samp>
elements are, by default, rendered in monospace font, they should not be used in place of the <pre>
element, as the element is recognized by user agents to have a specific meaning and is treated
appropriately.
CHALLENGE 3.11
Use the <pre> element in the same body of text as the <code>, <kbd>, and <samp> elements to
compare the outputs.
FIGURE 3.30 The example usage of the address and time elements.
CHALLENGE 3.12
Why is the <br> element used in the <address> element in the example to place the address lines on
separate lines, instead of the <p> or <div> element, since these elements too begin on a new line?
In the example, the <details> element contains the hidden text and the <summary> element provides the
heading for the element. If the <summary> element is not used, the name of the element is used for the
heading.
CHALLENGE 3.13
Implement the example, but without the <summary> element, to see what happens. Also, can you
think of an example of when you might use the technique of hiding text until it is requested in a
document, and say what the pros and cons of the technique are?
CHALLENGE 3.14
In the example, what difference would it make if the message is not placed in a <p> element and
when it is placed in a <div> element?
CHALLENGE 3.15
Write an HTML code to display the following content as it is:
Item Price: €59.99
<div id=“character”>
Gigabyte > Kilobyte < Megabyte
CHALLENGE 3.16
Write an HTML code to display the content within the quotes:
“Fill in the blanks:
The browser only displays space.
Browsers and screen readers are types of agents.”
3.19.1 lang
The lang attribute specifies the base language of the attribute values and content of an element. It is
intended to make browsers render a Web page meaningfully, based on the accepted usage for a specified
language. It is inherited, and the value it takes is a language code that represents a natural language. A
language code comprises a primary code and a possible sub-code. The primary code is a two-letter
code that represents a language abbreviation, and the sub-code represents a country code. In the language
code “en-US,” for example, “en” is the primary code and represents English, and “US” is the sub-code
and represents USA. The entire language code means US version of English. Most languages require only
the primary code. Common primary codes include fr (French), it (Italian), de (Germany), nl (Dutch), es
(Spanish), el (Greek), pt (Portuguese), ja (Japanese), zh (Chinese), ru (Russian), and he (Hebrew).
Relevant language codes can be found in IANA Language Subtag Registry at iana.org. Figure 3.42
shows examples of how the attribute is used.
Notice in the example that the lang attribute is used on the <html> element and then on the child
elements, as necessary. You should always use the attribute on the <html> element, not on the <body>
element, to ensure that the text inside the <head> element is covered.
CHALLENGE 3.17
Using the lang attribute on the <head> and <body> elements instead of using it on the <html> element
will not work; True or False? Give reasons for your answer.
CHALLENGE 3.18
If you have a phrase in a paragraph that is in a different language from the one used in the rest of the
paragraph, how do you isolate it, so that you can specify its language code and also give it a different
color?
3.19.2 dir
The order in which browsers display text depends on the base direction set for, or inherited by, the
element that contains it. The attribute used to set base direction is the dir attribute, and the values it takes
are ltr (left to right), rtl (right to left), and auto (which leaves it to the user agent to decide). The default is
ltr. It is inherited and can be overridden. It is useful to note that the attribute does not actually affect the
order in which the characters of text are displayed, but it affects only the order of the words. It only helps,
in combination with other processes, determine how the browser handles the display of text. In some
cases, it only visually aligns text left or right.
The way the determination of text direction works in browsers is that each character in Unicode
(introduced in Chapter 2) has a directionality property associated with it. Some characters are designated
as ltr (left to right) and others as rtl (right to left). In addition, Unicode provides the Unicode
bidirectional (bidi) algorithm, which is used to display these characters, using their directionality
properties. Browsers, by default, determine the direction in which to display a sequence of characters
(e.g., a word), using the bidi algorithm, and do this automatically, independently of the current base
direction. For example, for a sequence of Latin characters, it displays one after the other from left to right,
and for a sequence of Arabic or Hebrew characters, it displays one after the other from right to left.
Therefore, the word “forward” in English, for example, is displayed from left to right, while the same
word in Arabic is displayed from right to left.
This means that the base direction set with the dir attribute is used only to determine the direction in
which the words are displayed. Basically, it makes the word that is displayed first in left-to-right
direction display last in right-to-left direction, and vice versa. Incidentally, the bidi algorithm can be
turned off, using the <bdo> element (or bidirectional override element), which overrides the current
directionality properties of characters. Sometimes, it is necessary to do this when the algorithm does not
produce the desired result. This usually happens when different languages are mixed in the same text. The
use of the dir attribute is mandatory for the <bdo> element. Another element that can be used to resolve
problems from mixing languages is the <bdi> element (or bidirectional isolation element), which can be
used to isolate text that needs to be formatted differently from the surrounding text. However, this element
is not supported by all major browsers. An alternative way of resolving the same issue is to use an inline
element (such as the <span> element) to isolate the relevant text and then use the dir attribute. Figures
3.43 and 3.44 show some examples of how these attributes and elements are used and the effects.
FIGURE 3.43 Examples of how the dir attribute and <bdo> element are used.
FIGURE 3.44 The result of Figure 3.43.
In the example, the content of the first <p> element is displayed using the default ltr base direction. In
the second, specifying ltr does not make a difference. In the third, rtl starts the text from the right. In the
fourth, the Hebrew text is not displayed from the right, as it should be, because the default ltr base
direction is used. Note that the bidi algorithm still ensures that the characters of each word are displayed
correctly. In the fifth <p> element, specifying rtl makes the text display correctly from the right. In the
sixth, two different languages are displayed using default base direction. This makes the Hebrew text to
display improperly from right to left. In the seventh, the <bdo> element overrides the bidi algorithm for
the Hebrew text and sets the base direction to rtl. The <bdi> element is also used to isolate W3C to
ensure that it is displayed from left to right, since it is English. In the eighth <p> element, the <bdo>
element is used to override the bidi algorithm and set the direction to rtl, even though the correct direction
for displaying the text is from left to right.
CHALLENGE 3.19
What does the dir attribute do in relation to the characters in a word, and why is it not necessary to
specify it for text that is displayed from left to right?
CHALLENGE 3.20
In terms of their effects on the direction of text, what are the differences between the dir attribute and
the <bdo> element?
Ruby text is usually smaller and thinner than the base text, and its use is especially common in East
Asian text, such as Chinese, Japanese, and Korean (CJK) text. The elements used to implement it are
listed in Table 3.5.
The elements in the table can be combined in various ways to produce the same result. For example,
each pair of <rb> element and the corresponding <rt> element can be placed in <ruby> elements, or a
sequence of <rb> elements and a sequence of corresponding <rt> elements can be placed in the same
<ruby> element. Some examples of usage are presented next.
TABLE 3.5
Ruby Elements
3.20.1 <ruby>, <rb>, <rt>, and <rp>
Figure 3.46 shows how the <ruby>, <rb>, and <rt> elements are used, and Figure 3.47 depicts the result,
using the Chinese text for “Red Dragon is Alive!” The base text is in simplified Chinese, while the ruby
text gives the traditional Chinese equivalence.
In Figure 3.46, notice that there are equal numbers of <rb> and <rt> elements in the <ruby> element.
Each <rt> element is associated with the corresponding <rb> element and is displayed above it or to the
right of it. However, in Figure 3.47, notice that some ruby characters are missing above some base
characters. This is because the ruby characters are the same as the corresponding ruby base characters,
and it is redundant to show them twice. In cases where there is no ruby character for a ruby base, an
empty <rt> element must still be included in order to ensure correct matching between the base and ruby
characters. It is also worth noting that a space can be put between the characters by having a space
between the <rb> elements or having them on separate lines.
Figure 3.48 shows the same code as in Figure 3.46, but with the <rp> element used to add parentheses
to enclose the <rt> elements, so that browsers that do not support ruby text can ignore them. Notice how
this is done (shown in bold). The left parenthesis is added with <rp>(</rp>, and the right parenthesis is
added with <rp>)</rp>. The code produces the same result as Figure 3.47, in browsers that support ruby
text.
CHALLENGE 3.21
In Figure 3.46, what will be displayed if the ruby markup is not used?
CHALLENGE 3.22
In the examples, what will happen if the <rb> elements are placed on different lines?
CHALLENGE 3.23
The <span> element can be used in place of the <rb> element. Given this, replace the <rb> elements
in Figure 3.46 to see the effect. Also, can you think of the pros and cons of using either element?
CHALLENGE 3.24
Using Figure 3.46 as guide, create the following with ruby elements.
4.1 Introduction
Traditionally, lists and tables are essential tools in print media for imposing structure on content. Their
application in Web design is no different. They can also be combined with links, especially lists, to
extend their application. This chapter discusses the HTML elements used to create them.
4.3 Lists
HTML allows you to create three different types of lists:
Unordered lists, which are lists in which items begin with bullet points.
Ordered lists, which are lists in which items start with numbers or alphabets and are in numeric
or alphabetical order. Naturally, this is used only where the order of list items matters to meaning.
Definition lists, which are lists made up of terms and the definitions for each of the terms.
The general principle that underlies how any of these lists is created is to first specify type of list and then
the items of the list. Table 4.1 lists the relevant elements.
TABLE 4.1
The List Elements
Figure 4.1. demonstrates how the elements are used, and Figure 4.2 shows the rendered result. It is
useful to know that lists are indented by browsers by default, and all the elements are block-level
elements. In addition, the list elements add space at the top and bottom by default and the size of the space
is about the default font size used by the browser.
FIGURE 4.1 Example usage of all the list elements.
CHALLENGE 4.1
State the type of list that you would use for the content in the following document in order to
communicate it effectively and explain why? Then, write an HTML code to implement it.
CHALLENGE 4.2
Write the HTML code to insert another list after the first list item in the second-level list of both the
unordered and ordered lists in the example to see how the browser handles a three-level list by
default.
4.4 Tables
Various types of information benefit from being presented by using a table. Tables are especially crucial
for representing complex data, such as stock reports and time tables. The typical properties of a table are
illustrated in Figure 4.7, all of which can be represented using HTML, except width, height, cell padding,
cell spacing, and various other types of styling, which are defined by using CSS.
Table 4.2 describes the HTML table elements used for defining the structural properties of a table.
TABLE 4.2
Some Commonly Used Table Elements
FIGURE 4.9 The rendered result of Figure 4.8, with and without border.
Notice that even when a cell is empty, an empty <td> element is still used to represent it; otherwise,
the table will not look properly when put together. Also notice that the contents of the <th> elements are
displayed in bold. They are also displayed in the middle of the cell. Using the <th> element for headings
(instead of using the <td> element and making the contents bold manually through CSS) is especially good
practice, as user agents, such as screen readers, recognize the element and are therefore able to render it
in the way that best communicates the contents of a table to the user. The element also enables pages to be
indexed more effectively by search engines. In the example, there are both row headers (i.e., apples,
bananas, and grapes) and column headers (i.e., item, bought, sold, and balance).
CHALLENGE 4.3
Write the code for creating the following table. You can ignore the border, since it is supposed to be
implemented by using CSS.
FIGURE 4.10 Example usage of the <colgroup> element with the <col> element.
FIGURE 4.11 Example usage of the <colgroup> element without the <col> element.
CHALLENGE 4.4
Create the following table and group the columns that have the same color. Again, you don’t need to
implement the border.
FIGURE 4.13 Example usage of rowspan and colspan attributes in cells merging.
CHALLENGE 4.5
Write the HTML code for the table below. You can again ignore the border. The centering of the
content of the data cells is left as another exercise in Chapter 17, after the property for centering
content has been introduced.
FIGURE 4.15 Example usage of the <thead>, <tbody>, and <tfoot> elements.
Notice that the code in the example is the same as that in Figure 4.8, except for the addition of the scope
attribute to the cell of each row that is a header (but not in the first column) and the cells of the first row
that are headers. Basically, as a general rule, all <th> elements and <td> elements that act as headers
should have a scope attribute. The attribute does not affect the appearance of a table, so the code in the
example produces the same result as in Figure 4.9.
4.4.4.2 The id and headers Attributes and Accessibility
As introduced in Chapter 2, the id attribute is a global attribute used to give a unique identity to an
element. The headers attribute, on the other hand, is used to associate one or more header cells with a
table cell. Its value must correspond to the id attribute of the <th> element with which it is associated.
When multiple values are specified, the values are space-separated, each value again corresponding to
the id attribute of the <th> element with which it is associated. The technique is usually suitable for the
situation when the use of the scope attribute is not enough to describe the relationships between table
headers and data cells, such as when data cells are associated with more than one row and/or column
header. Figure 4.17 shows how the attributes are used together, and Figure 4.18 shows the created table.
Notice that as with the scope attribute, the id and headers attributes do not affect the display of a table.
Again, note that the border has been added by using CSS, and this has been done just to make the table
clearer to see. In the first table row element, the <th> elements are given c, t, and e identities,
respectively. In the second table row element, each <th> is given an id and is also associated with the
corresponding <th> element defined in the first <tr>, using the headers attribute. In the third table row
element, the headers attribute is used to associate each <td> element with the appropriate <th> element.
CHALLENGE 4.6
Add id and headers, as appropriate, to the example in Figure 4.13 to make the table more accessible.
NOTE: Designing tables
Tables are ideal for presenting specific values intended for easy and efficient access and
comprehension. However, in order for them to perform these functions effectively, they need to be
designed properly in a way that is logical and aesthetically pleasing. Guidelines on how to
achieve these are presented in Chapter 17, where how to style tables is discussed.
4.5 Links
Links, technically known as hyperlinks, are the very essence of the Web, because they are the feature that
enables interconnection between pages and browsing, without which the Web would be non-existent. The
common types of links are as follows:
Linking from a page to another website.
Linking from a page to another page on the same website.
Linking from a part of a page to another part on the same page.
Linking from a page to a specific part of a page on another website.
Linking from a page to an e-mail program to start a new message.
The element used to create all these types of links is the <a> element (known as anchor element). The
element defines an anchor but not the hyperlink; the hyperlink reference attribute, href, and a value
(which must be a URL) are required to do this, as shown in Figure 4.19. The content between the opening
and the closing tags is what is turned into a hyperlink.
In the example, the text “Click here for BBC” is made a link, so that when it is clicked, the Web
browser fetches the document “index.html” from the local hard disk cache, if a copy has been cached
(saved), or requests it from the Web server at the location “http://www.bbc.co.uk” and displays it. By
default, a new page replaces the current one in the browser window, unless the browser is instructed to
display the new page in a new window, using the target attribute, which was introduced in Chapter 2.
FIGURE 4.20 Example usage of the <a> element for external links.
CHALLENGE 4.7
Create the menu links in Figure 4.21 but without using the list elements to produce the following:
CHALLENGE 4.8
Write the HTML code to display the content between the quotes in the paragraph below, linking the
word “Earth” to https://en.wikipedia.org/wiki/Earth.
“The Solar System is made up of the Sun and the objects that orbit it. One of these objects is the
planet known as Earth, which is where we live.”
FIGURE 4.22 Example usage of the <a> element for within-site links.
CHALLENGE 4.9
Implement the code in Figure 4.23, but leave out the # symbol from value of the href attributes that
specify the destination section to see what happens.
FIGURE 4.25 Using the name attribute for the example in Figure 4.23.
CHALLENGE 4.10
What will happen if the name attributes in the example are on the header elements instead of being on
the <a> elements, and what is the problem with this, if any?
CHALLENGE 4.11
Which of the above two approaches do you think is more efficient and why?
5.1 Introduction
On-line forms are an essential means of collecting information from users, and most websites require the
completion of a form for one purpose or another. They are basically the screen version of traditional
paper forms, and most of the features commonly used in paper forms translate well into screen forms.
Like paper forms, they can be of any size, but they also incorporate other features, such as buttons, drop-
down list, and buttons, and can be interacted with in various ways, including via mouse, digital pen, and
touch. This chapter introduces the various elements used to build a Web form.
The <form> element is the element that is used to hold all the various elements that are used to describe
the features of a form. The elements used to collect input are known as form controls. A control must
have a name. The information entered by the user is associated with this name, and both are sent by the
browser to the Web server as a name-value pair. For example, in the illustration in Figure 5.1, if the
names given to the controls are fname, lname, and email, respectively, then the name-value pairs sent
would be fname=Joe, lname=Bloggs, and email= [email protected] . The <form> element allows
these pairs to be sent to the Web server through the use of the action and method attributes. The action
attribute allows you to specify the URL of the script to use by Web server to process the data, and the
method attribute allows you to specify how the data should be packaged and sent to the Web server. The
two possible methods are GET and POST, each of which is suitable for different situations.
With the GET method, the pairs are added to the end of the URL specified in the action attribute,
separated by “?,” with the pairs joined using “&.” Therefore, if, for example, the specified URL is
“http://www.test.com/register.php,” then what is sent will be: http://www.test.com/register.php?
fname=Joe&lname=Bloggs& [email protected]
Situations for which the GET method is well suited include when the amount of collected data is small
and is going to be used for searching a database. It is not suitable for a lot of data, because it supports
only 1024 characters. It should also not be used for sensitive information, because people can easily hack
into it. It also does not support binary data, such as image files and Word documents.
With the POST method, the pairs are sent via what are called HTTP headers. The pairs are joined in
the same way as in the GET method, that is, by using “&.” The method is suitable for all the uses
described above, for which the GET method is unsuitable. Figure 5.2 shows how the action and method
attributes are used with the <form> element.
In addition to the action and method attributes, the <form> element supports other attributes that are
commonly used. Table 5.1 lists them, starting with the two already mentioned.
FIGURE 5.2 Using the action and method attributes with the <form> element.
TABLE 5.1
Common Attributes Supported by the <form> Element
5.4.1 <input>
The <input> element is the most commonly used in forms, because it is used to display different types of
controls. It is an inline element, which means that the <br> element or a block-level container element
(e.g., <div> or <p>) must be used to go to a new line. It takes many attributes. The most important is the
type attribute, as it specifies input type and the type of control interface that is displayed, which includes
text-input field, radio button, checkbox, and drop-down menu. Other attributes specify the behavior of
these controls. Although there are many input types, their usage is based on the same principle, using the
following format:
<input type=“value”>
Different sets of attributes are used with different input types. Some are mandatory, and others are
optional. They will be introduced, as necessary, as the input types are presented.
TABLE 5.2
Form Controls and Elements Used with Them
TABLE 5.4
Attributes Supported by Input Types that Display Text Fields
Figure 5.3 shows how the types in Table 5.3 are used, along with the commonly used attributes in Table
5.4. Figure 5.4 shows the result.
In the example, notice that all the input types have a similar format. The attributes used to perform the
functions are described in Table 5.4. The Username and Password fields have been completed for the
purpose of demonstration. The non-letter characters displayed in the password-input type field are
automatic and for the purpose of preventing others from knowing what the user types. The required
attribute ensures that a form is not allowed to submit until the user has completed the input for the element
that has it. Notice that it does not have any value. The longhand is required=“required”, which is
unnecessary. Since the attribute does not usually provide any visual cues until after a form has been
submitted and the browser has prompted that a control must be completed, it can be useful to include
some visual means of informing users of the controls that must be completed, so that they know
beforehand. For example, the background or border of a field could be made with a different color from
those of other controls. This is achieved using CSS, and how it is done is explained in Chapter 17.
The use of the required attribute is a part of a process known as form validation, which involves
checking a submitted form to ensure that all the required inputs have been completed and the inputs are of
the correct type and/or format. It is an important process, because it ensures the integrity of submitted
form data. Traditionally, this was done using client-side JavaScript scripting. However, HTML now has
attributes to help with the process. One of them is the required attribute. Another is the pattern attribute.
Although the attribute is not used in the example, it can be useful for ensuring that users enter certain types
of information, such as e-mail address, correctly. It is easy to specify. However, deriving the correct
regular expression (also called regex) to specify can be difficult, because it involves mathematics.
Figure 5.5 shows an example being used.
The expression is used to verify that user input comprises three upper- or lowercase letters, followed
by six digits. The content of the title attribute in the code is displayed when the cursor hovers over the text
field. If the user enters an input whose format does not match the pattern, the browser immediately
prompts him or her to re-input the data and also reminds him or her of the correct format. Using the
attribute with email and password input types can be especially useful for ensuring that correct e-mail
formats are inputted and that the passwords chosen by users are varied and complex and therefore
difficult to guess by hackers. To ensure password complexity, users are compelled to include a wide
variety of combinations of lower- and uppercase letters, numbers, and characters. The explanation of how
regular expressions are formulated is beyond the scope of this book. However, there are useful
expressions on the Web. It is not important to understand how they work to be able to use them. You only
need to know what they do.
Refer to Figure 5.3 and notice the text in the email field, which is placed there with the placeholder
attribute. It is temporary and disappears the moment the field receives focus or the user starts to type into
it. Next, notice that the Search text field is filled with the word “bolts” by default. This is the effect of
specifying the value attribute in the search-input type. In contrast, the hidden-input type does not display
anything. It simply creates a name-value pair, “subject=registration,” which is sent to the server when the
form is submitted and used by the relevant script for decision making. An example of how the input type is
used is when the same script is used to process more than one form. Giving different hidden values to
each form makes it possible for the script to identify which form has been submitted and process it
accordingly. Finally, notice that the fields in the example are not vertically aligned. This is done using
CSS and is dealt with in Chapter 17.
CHALLENGE 5.1
To see the effect of the pattern attribute, include it in the example in Figure 5.3 and then use the
regular expression “[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$” as its value to check the e-mail
field. Remember to include the title attribute.
5.4.1.1.2.2 Input Type: range The range-input type displays a slide control for inputting an integer
(whole) number, as opposed to decimal number. Figure 5.8 shows how it is used, and Figure 5.9 depicts
the result. As in the previous example, the min and max attributes specify the range of numbers covered by
the slide and the value attribute sets the initial number as 0.
The disadvantage of the range-input type is that it does not display any number. However, this
functionality can be added using additional elements and attributes. Figure 5.10 shows an example of how
to do this, and Figure 5.11 depicts the result. The <output> element is responsible for displaying the
numbers, and its initial content is set as 0. In the <input> element, the min and max attributes specify the
range of numbers covered by the slide; the value attribute sets its initial number as 0; and the oninput form
event attribute says that when an input is made (i.e., when the slide is moved), the value of the element
bearing the name “quantity” should be replaced with the value of the one bearing the name “slideInput.” A
form event attribute, as you may recollect from Chapter 2, is an event generated by a form element when
its state changes.
In the previous example, the number displayed cannot be edited. However, it is possible to make it
editable and also link it to the slide, so that the user can use either of the two to make an input. This can be
done by combining the range-input type with the number-input type. Figure 5.12 shows an example,
and Figure 5.13 depicts the result. In the number-type <input> element, the oninput attribute specifies that
when the user enters a number in the box, the value of the range-input type should be replaced with that of
the number-input type. The reverse happens with the oninput attribute in the range-type <input> element
when the slide is moved. All other attributes play the same roles, as described in the previous example.
FIGURE 5.12 Combining editable number field with the <output> element.
CHALLENGE 5.3
Can you think of a situation in which the number control is applicable? Also, how would you change
the text box in the example to a non-editable field?
CHALLENGE 5.4
In which situations you might use the time control?
5.4.1.1.3.2 Input Type: date The date-input type displays a single-line formatted text box and a drop-
down calendar for setting date. The input format allowed by the text field depends on the date convention
of the region of the world of the user. Figure 5.16 shows how it is used, and Figure 5.17 depicts the result.
To use the control displayed, the user, like with the time-input type control, clicks the relevant date
component and types in a value or uses the up and down arrows. Various other arrows allow you to
navigate to the required month and year.
5.4.1.1.3.3 Input Type: datetime-local The datetime-local-input type displays a text box and a date and
time control for setting local date and time. Figure 5.18 shows how it is used, and Figure 5.19 depicts the
result. The control displayed allows you to choose a date by clicking the downward arrow to display the
calendar and then clicking a day on it. The time is entered by clicking the hour, minutes, or seconds
component and by using the arrows to set the values. It is worth noting that HTML also specifies a
datetime-input type, which is intended for setting global date and time, including time zone information.
However, it is not, as of time of writing, supported by any major browser.
CHALLENGE 5.6
Implement the example and interact with the features and then suggest in which type of application
you might use the control. Also, using the earlier example under the number-input type as guide,
experiment with the min and max attributes for possible applications.
5.4.1.1.3.4Input Type: month The month-input type displays a formatted text box and a month-and-year
control for setting month and year. Figure 5.20 shows how it is used, and Figure 5.21 depicts the result.
The control allows you to choose a month by clicking the downward arrow to display a calendar and then
clicking the next or previous arrow to navigate to the desired month. Alternatively, you could click the
button that displays all the months, to choose one.
FIGURE 5.20 Example usage of the month-input type.
CHALLENGE 5.7
Implement the example and interact with the features and then suggest in which type of application
you might use the control. Again, using the earlier example under the number-input type as guide,
experiment with the min and max attributes to get a better idea of how you might apply them
effectively in a design.
5.4.1.1.3.5 Input Type: week The week-input type displays a text box and a week-and-year control.
Figure 5.22 shows how it is used, and Figure 5.23 depicts the result. The displayed control allows the
user to choose the date by clicking the downward arrow to display a calendar. Different Web browsers
display the control differently.
CHALLENGE 5.9
Implement the example in Figure 5.24 but with buttons arranged vertically.
CHALLENGE 5.10
For which of these would you use radio buttons?
Please select your favorites.
Please choose your gender.
Do you agree with the terms and conditions?
Please choose one.
Please choose.
CHALLENGE 5.11
For which of these would you use checkboxes?
Please select your favorites.
Please choose your gender.
Do you agree with the terms and conditions?
Please choose one.
Please choose.
Like the submit-input type, the reset-input type displays a push button, but when clicked or pressed, it
clears user’s inputs and resets all the controls of a form to their default values. Unlike the submit-input
type, it supports only the name, value, disabled, autofocus, and form attributes. Figure 5.28 shows how
both input types are used, and Figure 5.29 depicts the result.
CHALLENGE 5.12
Add the necessary things to the code in Figure 5.28 to produce the form below:
5.4.1.3.2 Input Type: image
The image-input type allows you to specify an image to be used as a submit button. It supports the same
attributes as listed in Table 5.7 for submit- and reset-input types, as well as the image-specific ones
listed in Table 5.8. Figure 5.30 shows how the input type is used, and Figure 5.31 depicts the result.
TABLE 5.8
Attributes for Image Button
Attribute Function
src Specifies the URL of the image to use.
width Specifies the width of image.
height Specifies the height of image.
alt Specifies the alternative text to use to describe image. It is essential for accessibility.
The actual size of the image used in the example was 200 × 50 pixels and was reduced to 148 × 30
pixels. It is good practice to create an image that is as close as possible in size to the one required.
This is because the process of reduction can cause problems, such as making the text on the image too
small to be legible. If the image specified is not found, a visual predetermined by the browser is
displayed instead. This can be just text or a box with text in it.
Unfortunately, unlike the submit- and reset-input types that perform predetermined functions when
activated, the image-input type needs to be told what to do when it is activated, and this is typically done
using the onclick event attribute (which generates an event each time the element on which it is used is
clicked) and the submit() JavaScript function (which submits a form when it is called). For example,
adding onclick=“submit();” to the <input> element in Figure 5.28 says to submit the form when the
element (i.e., the image button) is clicked.
CHALLENGE 5.13
Try the example in Figure 5.30 but without providing the correct location for the image, and see what
happens in different browsers.
CHALLENGE 5.14
Try the code by using different types of browsers to see the differences in rendering.
CHALLENGE 5.15
Add a submit button to the example that will serve to upload the selected file.
CHALLENGE 5.16
In what type of Web application would you need to use the color-input type, and why could you not
just ask users to enter the hex code or name of the color that they want in a text-input field?
The code in the example displays a color button, which when clicked displays the color picker. The
hexadecimal value (or hex code) of the color selected is what is stored and sent to the server. In theory,
it is as if the user has entered the value into a text-input field.
CHALLENGE 5.17
What additional information do the images on the buttons in the example provide, and which types of
application do you think would benefit from these kinds of buttons?
CHALLENGE 5.18
Implement the example by using your own images and then specify the wrong locations for the
images. Also, omit them altogether and see what happens.
CHALLENGE 5.19
What is the basic difference between the textarea control and the controls for the text-input types?
TABLE 5.14
Attributes for <option> Element
Attribute Function
value Specifies a value for option.
label Specifies a label for option.
selected Specifies to select option by default. It can be specified by itself, without a value (instead of selected=“selected”).
disabled Specifies to disable control, so that user cannot interact with it. It can be specified by itself, without a value (instead of
disabled=“disabled”).
FIGURE 5.44 Using the multiple attribute with the <select> element.
The <select> element also supports the selection of multiple options when the multiple attribute is used
on it. The value of the size attribute can be set high to show many or all the options at once in order to
make this easier. Figure 5.44 shows the result of the same code in Figure 5.42 but with the multiple
attribute specified and the size attribute set to 6. Users can select more than one option by holding down a
modifier key (e.g., Shift or Ctrl in Windows and Command or Option in Mac) while clicking the options.
In the example, three options are selected. However, the use of multiple select menus is not
recommended because of the difficulty in using them. For example, many people may not know how to
use modifier keys. It may be better to use checkboxes where users are allowed to make multiple
selections.
CHALLENGE 5.20
Render the code in Figure 5.42 and experiment with the multiple and size attributes to see the effects.
Also, notice that the list is displayed upward. Place the select control under the prompting text, on a
separate line instead of placing it on the same line, and see how this behavior changes.
5.4.4.2 <datalist>...</datalist>
Like the <select> element, the <datalist> element creates a drop-down list, but it works in a different way.
It works in combination with the text-type <input> and <option> elements, so that what is typed inside the
text field determines the options displayed on the drop-down list. The element takes no special attributes;
it takes only global ones, such as id. Figure 5.45 shows how it is used, and Figure 5.46 depicts the result.
In the example, when the user clicks, double clicks, or starts typing in the text-input field, the drop-
down list is displayed, from which the user can choose one. If it is a long list and the desired item is not
visible, then, as the user starts typing the desired word, the items are narrowed down to those that match
the most to what is currently typed. However, for the element to work properly in this way, the value of
the list attribute on the <input> element must match the value of the id attribute on the <datalist> element,
which is “browsers” in this case.
CHALLENGE 5.21
Implement the example and make the text box appear under the label instead of making it appear to
its right. Also, interact with it to see how it works to better understand how to use it.
CHALLENGE 5.22
For which of the following would you use the <progress> element and why?
The number sold from stock of an item.
Time-based information.
State of stock of an item.
Provide information about how full a theater is.
The sales of tickets for a concert.
CHALLENGE 5.23
For which of the following would you use the <meter> element?
The number sold from stock of an item.
Measure of sales.
State of stock of an item.
The example shows two numbers being added together, as each is inputted by the user. The number-
input type (discussed earlier) is used to collect each number, and the <output> element displays the
content of the value of the name attribute (i.e., “sum”). The oninput event attribute on the <form> element
takes care of the addition of the numbers and the placing of the result in “sum.” The equation says to take
the values stored in “a” and “b,” use the valueAsNumber function to change each to a number, add the
numbers together, and then make the result the value of the element named “sum.” Notice the dot
convention. This is the convention used in object-oriented programming to specify to access what is
stored in a variable or apply a function to it.
CHALLENGE 5.24
Write a code that displays the result of three numbers inputted by the user, the first two of which are
added together and the total multiplied by the third.
In some cases, the purpose of a form control may be clear enough, such that adding a label will create
redundancy visually. An example is a text field that has a search button next to it. In such cases, although
label is still added to make the control accessible to assistive technologies, it is made invisible by hiding
it by using CSS. An alternative is to use the aria-label attribute, which provides a label to identify a form
control to assistive technologies but does not provide the information visually. Figure 5.55 shows how the
attribute is used, and Figure 5.56 depicts the result. Although the title attribute can also be used for this, it
is not supported by some screen readers and assistive technologies.
FIGURE 5.55 Example usage of the aria-label attribute.
NOTE: Accessibility
If an image, such as an asterisk, is used in front of the label of a required control, then the
<label> element should encapsulate it.
Form buttons (e.g., submit-input and reset-input types and <button> element) do not
require additional accessibility information. The value of the value attribute used with the
<input> element and the content of the <button> element provide the necessary
information for the screen reader.
When an image-input type is used for a button, the alt attribute should be used with the
<input> element to provide accessibility information.
If a form control is not labeled, because it is apparent visually, then a hidden label should
be considered.
CHALLENGE 5.25
Why is the following poor labeling practice for accessibility?
<label>Select ice cream flavor
<select name=“flavor”>
<option>Vanilla</option>
<option>Chocolate</option>
<option>Strawberry</option>
</select>
</label>
CHALLENGE 5.26
How would you label the following to make it accessible? (Hint: label each item separately):
<div>Select ice cream flavor</div>
<ul>
<li><input type=“checkbox” id=“a1”
value=“vanilla”>Vanilla</li>
<li><input type=“checkbox” id=“a2”
value=“chocolate”>Chocolate</li>
<li><input type=“checkbox” id=“a3”
value=“strawberry”>Strawberry</li>
</ul>
CHALLENGE 5.27
What would happen if the <legend> element is used without the <fieldset> element?
CHALLENGE 5.28
Insert appropriate markup in the code in Figure 5.59 to create line space between the controls, so
that the form looks more spacious.
6.1 Introduction
Images have functions in almost everything we do that involves communication. Next to text, they are
perhaps the most prevalent form of communicating content on the Web. Not only this, they have an
indispensible role in the aesthetic appeal and the theme setting of Web pages. This chapter introduces the
HTML elements used to add images, as well as design principles that guide effective use of images in
Web design.
The title attribute, which is a global attribute, provides additional description for the image and is
usually displayed when cursor hovers over an image, as shown in the rendered example. However, the
attribute should not be used for essential information, since you cannot rely on everyone having access to
it, because not every user uses a mouse and some browsers may not display it.
The width and height attributes specify the rendered size of the image. Rendered image size can also be
specified using CSS. Both approaches have advantages and disadvantages. Most importantly, specifying
size by using attributes enables faster download and more orderly rendering of a page. It also prevents
layout from having to be reflowed multiple times as the page loads. This is because text usually
downloads faster than images and the browser by default does not know the size of an image. The result
of this is that when the attributes are not used, text finishes downloading, the browser displays it, and then
moves it around to fit in the image when the image finishes downloading, resulting in an untidy rendering
process. In contrast, when the width and height attributes are specified and the browser encounters them,
it reserves the right amount of space for the image and displays the text accordingly, so that when the
image finishes downloading, it fits it in, without having to move the text significantly around. On the other
hand, specifying size by using CSS (discussed in Chapter 15) allows for size to be controlled dynamically
and also overrides whatever size is specified, using the width and height attributes.
Challenge 6.1
Which of the following is a better use of alternative text for an image of a garden covered in snow,
and why? Also, can you write a better one?
<img src=“image/garden.jpg” alt=“Garden”>
<img src=“image/garden.jpg” alt=“My garden in winter”>
CHALLENGE 6.2
What is the difference between how the browser renders alt text and the title attribute, and which is
more valuable for accessibility?
CHALLENGE 6.3
If the image in the example was in a folder named “hobbies” that is inside a folder named “images”
that is inside the one containing the HTML document, how would you write the value of the src
attribute?
CHALLENGE 6.4
Assuming the file names of the following two images of a star, are “full_star.png” and
“empty_star.png”, write a code that displays the rating below, making the text alternative “Item
rating: 3 out of 5 stars.”:
CHALLENGE 6.5
In CHALLENGE 6.4, which of the five star images that form the rating should carry the alternative
text that describes the function of the images, and why? Also, if your answer is that only some of the
images should carry the function description, what should the alt values for other images be?
FIGURE 6.3 Using the <a> element to make an image a link and link to an image.
FIGURE 6.4 Rendered result of Figure 6.3. (Image from http://www.freeimages.co.uk.)
CHALLENGE 6.6
How can you achieve the same goal achieved with the <br> elements in the example without using
the elements?
CHALLENGE 6.7
In the code example, why is the <h2> element placed inside the <figure> element and not outside of
it?
In the example, the browser selects any of the image sources specified in the src- set attribute, using the
specified pixel density descriptors (l.5x and 2x), also known as display density descriptors. Essentially,
on displays with 1.5 device pixels per CSS pixel, the image with l.5x pixel density is used, and on those
with 2 device pixels per CSS pixel, the image with 2x pixel density is used. This means that browsers on
devices with high-PPI (pixels per inch) screens select a high-resolution image (i.e., one with l.5x or 2x)
and other browsers select a normal (lx) image. Where no x descriptor is specified, it is assumed to be lx.
If a browser does not support the srcset attribute, it uses the image source specified in the src attribute as
fallback. Newer browsers that support srcset attribute usually use the source as one of the options and use
it as if specified with a lx descriptor. How x descriptors work in relation to image dimensions is that if
the normal-resolution image is 400 x 268 and lx, then the image specified with l.5x should be 600 x 402
and the image with 2x should be 800 x 536. Notice that the naming of the image files matches the x
descriptors’ values. This is only good practice to avoid confusion and does not affect anything.
CHALLENGE 6.8
Implement the example and vary the width of the browser to see the behavior of the image.
CHALLENGE 6.9
If the dimensions of an image that you want to use with lx descriptor are 500 x 325 px, what should
be the dimensions for the l. 5x version?
CHALLENGE 6.10
Ensuring that you have created the necessary versions (shown in the example) of the same image,
implement the example and experiment with the width of the browser. Also, experiment with the
value of the sizes attribute to see the effect.
FIGURE 6.9 Specifying responsive images for viewport-size-based use case, using media condition.
CHALLENGE 6.11
Try out the example by using the images that you used in the previous challenge and experiment with
the width of the browser to see the effects of the media conditions. Also, experiment with the values
of the sizes attribute to see the effect.
In the example, the browser selects the first <source> element and evaluates the condition in the media
attribute. If it is true, it chooses the image source in the corresponding srcset attribute. If the condition is
false, the browser goes to the next <source> element and does the same thing. If all the conditions in the
<source> elements are false, the image source in the <img> element is used. This means that if the
browser’s width is 720 px or more, “images/yacht-fullshot .jpg” is selected; if the width is 512 px or
more, “images/yacht-midshot.jp< “ is selected; otherwise, “images/yacht-closeshot.jpg” is selected.
Notice that the dimensions of the images are not specified. They need to be specified, so that the
browser can allocate space for the images before they are downloaded and so prevent multiple reflowing
of layout during page rendering. To provide the dimensions, CSS properties and CSS media queries (or
media conditions) are used, and how to do this is explained in Chapter 15. Also, to provide the
dimensions for old browsers that do not support the <picture> element, the width and height attributes can
also be used on the <img> element.
CHALLENGE 6.12
Try out the example. To do this, open a full-shot image in an image editor program such as
Photoshop, then scale and crop it accordingly to produce the mid-shot and close-shot images, and
use them as in the code.
CHALLENGE 6.13
Assuming that you want to display a 640 x 480 image named “large-field.jpg” on screens that are
1024 CSS pixels wide or more and a smaller 320 x 240 image named “small-field.jpg” on screens
that are 1023 CSS pixels wide or less, write an HTML code to implement this.
CHALLENGE 6.14
Would the example work correctly if the <picture> element is not used and why?
6.3.2 <canvas>...</canvas>
The <canvas> element allows you to draw graphics on the fly. This enables the creation of dynamic
images, such as the ones necessary in games, generation of graphs, and other images in real time. The
attributes that it supports are width and height. Figure 6.13 shows how it is used. The example creates a
canvas that is 150 x 150 pixels in size and has a unique identification of “oneCanvas.” The fallback
statement is displayed if a browser does not support the element. Note that because the element is just a
container element, it does not display anything on its own, so the code does not display anything. How it
is combined with JavaScript to display images is discussed in Chapter 22.
6.3.3 <svg>...</svg>
The <svg> element makes it possible to add to a Web page a type of image known as vector image
(discussed more fully later in this chapter), which is created using coordinates. The element is useful for
creating basic images on the fly but requires the understanding of a different type of markup language
called SVG, which is beyond the scope of this book. Figure 6.14 shows how it is placed in an HTML
document, and Figure 6.15 depicts the result. In the example, the SVG <svg> element defines the image,
the width and height attributes define the size, and the SVG <rect> elements define the rectangles and their
sizes.
In the example, the first <area> element creates a hotspot shape of the London region, which when
clicked takes users to another page that provides information about the region. The second <area> element
does the same for the Northeast region, and all the other regions (i.e., hotspot shapes) are created in the
same way, all of which are enclosed within the <map> element. In the coords attributes, the first two
numbers specify the x-y coordinates of the first point of the shape being created, and the next two numbers
specify the x-y coordinates of the second point, and so on.
CHALLENGE 6.15
Using an online image map generator to generate the necessary coordinates, create an image map that
comprises two circular hotspots on an image of your choice, so that when each is clicked, the user is
taken to different sites. Also, apart from the type of application shown in the example, how else can
you use image mapping in Web design?
6.4.1 <iframe>...</iframe>
The <iframe> element is an inline element that allows content to be embedded in a page and interacted
with by the user in various ways. Embedding content in this way is useful for embedding interactive
applications, such as Google map. Commonly supported attributes are listed in Table 6.4. Figure 6.18
shows how it is used to embed interactive Google map, and Figure 6.19 depicts the result.
TABLE 6.4
The HTML5 Attributes for the <iframe> Element
FIGURE 6.18 Example usage of the <iframe> element.
FIGURE 6.19 The result of Figure 6.18.
Obtaining the value for the src attribute required going to https://maps.google.co.uk and searching for
London. Next, when the map for London was displayed, the three- line menu icon at the top-left corner of
the map was clicked to display a drop-down list, from which “Share or embed map” was chosen. Next, in
the dialog that appeared, the “Embed map” option was chosen and the code for embedding the map was
copied and used, as shown in the example. Note that the code generated by the site, as of time of writing,
has some attributes that are no longer supported by the <iframe> element and should therefore be
removed.
CHALLENGE 6.16
Write an HTML code for embedding the Google map for where you are. Also, in what type of
application would you use a map like this?
Representing images in pixels inevitably produces properties that can be used to describe bitmapped
images. These properties revolve around how many pixels are there in an image or specific area of it.
They influence image quality and therefore have design implications. The three main properties are image
resolution, pixels per unit length, and color depth.
However, cropping could also be used deliberately for this purpose in order to remove unwanted
details from an image and better focus on the important elements. In such a case, an image may first be
enlarged and then cropped, or vice versa. Figure 6.24 shows an example. Notice the difference in
presence, focus, and aspect ratio.
FIGURE 6.24 Enlarging and cropping an image to focus on a specific part. (Image from http://www.freeimages.co.uk.)
FIGURE 6.25 The relationship between the images of the same document scanned at 72 and 300 ppi.
So, what ppi should be used when creating images for Web design? Although computers and other
devices used to access websites generally have ppi that is higher than 72 ppi, there is no logical reason to
produce images intended for screen display at anything more than 72 ppi, since higher ppi will only result
in larger files. However, it is a different matter when images are intended to be printed.
CHALLENGE 6.17
What will be the dimensions of a 3000 x 2000 pixels image on the screen when displayed on a 72
ppi monitor?
Some technologies used for creating images, such as scanners, offer higher color depths than 24-bit,
such as 32-bit and 48-bit, but these are unlikely to produce any discernable benefits, since humans are
capable of differentiating only between about 10 million colors, most, if not all, of which are covered by
24-bit color depth. Also, humans are not very good at distinguishing between close variations of the same
color, unless they are placed close to each other. However, higher color depths can be useful, because the
extra bits can be used for other functions. For example, in 32-bit color depth, 8 bits are used, each for the
red, green, and blue color components (or channels) and the extra 8 bits for an alpha channel (or
transparency channel). An alpha channel specifies which parts of an image should be transparent and by
how much. Its value ranges from 0 to 255. When it is set to 0, the specified area of an image is fully
transparent, and when set to 255, it is fully opaque. The channel is usually controlled with the opacity
feature in graphics-editing programs and is usually specified as a value between 0% and 100% or
between 0 and 1.0. The alpha channel has an important role in the production of images.
Looking at the figure, it is easy to imagine that a more complex vector graphic would comprise many
more points, as shown in Figure 6.28. The figure shows a relatively complex vector graphic, which is
actually one object created by connecting many points (node points).
Storing only the coordinates of the objects and a few other properties that make up vector images
means that vector image files are seldom large in size, making the method an effective way of producing
good-quality digital images that are small in size. Also, because they are stored as a series of coordinates,
they can be scaled, translated, and deformed easily by simply manipulating the node points. This means
that they are very scalable (i.e., they can be enlarged without loss of image quality). Furthermore, their
quality is independent of display device resolution, meaning that they can look good on displays of any
resolution. Also, being small in size particularly makes vector images “Internet friendly,” in that they
download fast. Figure 6.29 shows examples of vector images. Image “A” is made up of many curves and
color fills, and image “B” is a good example of how vector graphics can be used to create complex,
highly detailed, and artistic graphics. The image, which is a digital reproduction of Alponse Mucha’s F.
Champenois Imprimeur-Editeur, is made up of numerous curves, shapes, shades, and effects, using a tool
called Gradient Mesh, which allows the easy manipulation of curves.
Some of the performance benefits of vector images are reduced by the fact that they still typically have
to be saved in bitmapped file formats in order to use them on Web pages. An alternative to doing this is to
save them in a vector-based format, such as SVG, mentioned earlier. SVG is both a vector graphics
language and a file format, such that when a vector graphic is saved, it is also saved in the language,
which a browser is then able to translate into a vector image and display. However, the use of SVG is not
yet widespread, as of time of writing.
Another alternative to saving vector images as bitmapped is to save them in Flash file format, SWF,
which is another vector-based format. However, a Web browser needs a plug-in in order to be able to
display a vector graphic saved in the format. Furthermore, the popularity of the format has decreased, and
this is unlikely to change, going into the future.
FIGURE 6.29 Some 2D vector graphics. (a) is from http://www.free-clip-art.com, and (b) is by Yukio Miyamoto. (Image from
http://www.bekkoame.ne.jp/~yukio-m/intro/index.html.)
Given that high-quality images produce very large files, it is often necessary to balance file size
against quality when producing images for Web design, because large files can cause performance
problems, such as long download time. It is no good, for example, if images are of very high quality and
pages take frustratingly long times to display, as most users will probably not be prepared to wait.
Similarly, it is no good to compress an image to the point that degradation is visible, as this might
compromise the information being communicated and/or user experience. Figure 6.30 shows the same
image with different compression levels and their effect on quality and file size. Notice the visible
degradation in 75% and 99% compressions.
FIGURE 6.30 An illustration of the effects of compression on quality and file size. (Image from http://www.freeimages.co.uk.)
To help with size-quality balancing, image production programs, such as Photoshop, typically provide
information about the size of the file generated by an image and also how long it will take to transmit the
file over a range of Internet connection speeds. However, while this information is readily available
when using these programs, it can be useful to know how to calculate image file size and transmission
time for when, for example, you are doing initial designing on paper and/ or have no access to a suitable
program. After all, just because we have calculators does not mean that we should not know how to add,
in case calculators are not available.
CHALLENGE 6.18
Assuming that you want to include a 4 x 5 inch image in an application and, because the image is
also going to be printed, you need to scan the image at 600 ppi and 24-bit color depth, calculate the
possible size of the image.
6.5.5 Calculating File Size Generated from Digital Camera
An image captured with a digital camera with pixel dimensions of 640 x 480 px at 24-bit color depth
produces a file size of 0.92 MB. This is calculated by multiplying the total number of pixels by the
number of bits per pixel to get the total number of bits and then dividing by 8 to get the number of bytes,
thus:
Document Image File Size = ( ( height × width ) × PPI 2 × color depth ) / 8 Image File Size = ( pixel
dimensions × color depth ) / 8
Using the formula gives:
Image File Size = ( ( 640 × 480 ) × 24 ) / 8 = 921 , 600 bytes = 921 , 600 / 1000 = 921.60 KB = 921.60 /
1000 = 0.92 MB
CHALLENGE 6.19
What is the file size, in gigabytes, produced by a digital camera when you take a photograph with
1600 x 1200 px dimension at 32-bit color depth?
CHALLENGE 6.20
A 20.25 MB image is embedded in Web page. Assuming that the size of the other contents of the page
is insignificant, determine how long it will take to transmit the page over 2 Mbps and 100 kbps
connections, respectively.
FIGURE 6.31 A demonstration of the effect of overwhelming background image and a possible solution. (Image from
http://www.freeimages.co.uk.)
Another common technique used to prevent background image from overwhelming content is to place
the content in a plain color box on the background, as shown in Figure 6.32. However, this can look a bit
messy, confusing, and distracting sometimes, especially when users have to scroll through the content.
Also, the background can keep attracting the eyes from the periphery.
FIGURE 6.32 Preventing background from compromising legibility.
When it is not feasible to place annotations on an image, connecting one element to the other directly,
using something like a pointing line, as illustrated in Figure 6.34, can provide a reasonable compromise.
CHALLENGE 6.21
Given the guidelines provided earlier under HTML, how would you make these types of images
accessible to the visually impaired?
6.7.3 Photography
This is an easier method of acquiring images than drawing or painting them, in that it mostly requires
pointing a camera and capturing an image; however, taking some types of photographs requires expertise,
in using both the right camera settings and techniques. There are two main types of cameras: point-and-
shoot and digital single-lens reflex (DSLR) cameras. Point-and-shoot cameras are compact and easy to
operate.
Although mobile phone cameras are a type of point-and-shoot cameras, some may not produce images
that are as good as dedicated point-and-shoot cameras, such as in low- lighting conditions. In contrast,
DSLR cameras are larger and more complex to operate but take better pictures.
In addition to using the right settings and techniques, there is also the matter of using the right lighting
setup to get the right mood. This usually involves using a combination of lights of different intensity
placed at different angles and distances to the subject. The most common lighting scheme is three-point
lighting. Naturally, shots from a camera can also be manipulated in graphics editors to correct
imperfections or to create effects. This is certainly necessary when producing high-dynamic-range
(HDR) images. Production of HDR images typically involves combining differently exposed shots of the
same scene (sometimes known as bracketed photos) and manipulating the properties of the resulting
single image, such as color saturation, luminosity, contrast, and lighting. Bracketed photos are typically
produced using auto-exposure bracketing (AEB) in cameras to capture three or more shots in sequence,
using different exposures.
HDR images are images intended to be expressive and communicate something that is closer to what is
seen in reality, such as the blurry yet sparkling points of light that the teary eyes see when looking at an
illuminated high-contrast scene at night, something that a camera, for example, is not capable of capturing.
They are used to create this type of realism, and more, including extreme and surreal visuals and typically
high contrast and vibrancy.
6.7.4 Image Scanning
This is another easy way to acquire images; however, the images have to exist first in a physical form,
whether on paper or on any other surfaces. Image scanners are typically hand-held or flatbed. Hand-held
scanners are portable but more difficult to operate in that they are prone to shaking, which produces
poor-quality images. Flatbed scanners are fixed, and using them requires simply laying an image on their
glass surface and operating accordingly. Various image properties, such as scanning resolution (i.e., ppi)
and contrast, can be set to ensure that the desired image quality is achieved. The use of 300 ppi is
common for images intended for screen display.
Because standard image scanners do not produce good-quality images from film negatives and slides,
these are scanned using a special type of scanner. They can be as easy to use as placing a negative in a
carrier that they come with and feeding it into the scanner. Typical scanning resolution is much higher than
that for normal scanning and ranges from 3000 to 4000 ppi.
7.1 Introduction
Audio, video, and animation are introduced together because they are dynamic media, which are media
that change continuously with time. These media are generally added to a Web page by using similar
principles. This chapter presents the various methods and elements used to add them to a Web page.
7.4 Audio
The HTML elements used to add audio to a Web page are the <a> element (used to link to audio) and the
<audio>, <embed>, or <object> element (used to embed audio).
CHALLENGE 7.1
In Figure 7.1, where is the audio file located in relation to the code. Also, in what situation is linked
audio more appropriate than embedded audio?
CHALLENGE 7.2
Write a code that includes the autoplay, and loop attributes to see how they work.
The <audio> element can also be combined with the <source> element to provide multiple audio sources,
from which the browser chooses the most suitable. The element is also used with other dynamic media
elements, such as <video>. The attributes that it supports are listed in Table 7.2. Figure 7.5 shows how it
is used. The code produces the same result as Figure 7.4.
TABLE 7.2
Attributes Used with the <source> Element When Adding Audio
Attribute Function
src Specifies URL of the source.
type Specifies the type of the source. It helps the browser to determine whether it can play a file before loading it. Value is a string that
identifies a valid Internet media type (or MIME type). Optional codecs parameters can also be added to specify how exactly the
source is encoded.
FIGURE 7.5 Example usage of the <audio> with the <source> element.
When the browser encounters the <audio> element in the code example, it goes through the list of
<source> elements and plays the first one that it can. If it cannot find any format that it supports, it
displays the message, if the browser supports this. Notice that the audio sources specified in the <source>
elements are the same, except for the values of the type attributes, which specify a different media type for
each source. The codecs parameters specified with the codec attribute on the first <source> element
specify the exact codec used to encode the source. A codec (derived from the two words: compressor and
decompressor) is the technology used to compress (encode) and decompress (decode) digital data file or
stream.
When specified, codecs parameters are one of the values of the type attribute and need to be in double
quotes, while all the values of the attribute are enclosed in single quotes. Specifying the parameters can
make the job of the browser easier, in that they help the browser determine whether or not it can play a
file without first having to load it. However, if parameters are used, it is important that they are correct;
otherwise, the browser will generate an error, even if it can play the specified file. On the other hand, if
the parameters are not specified, the browser will load the file as normal and discover that it supports the
file and play it. The full list of codecs parameters can be found on the Web. Table 7.3 lists some of the
commonly used codecs parameters for audio.
TABLE 7.3
Common Media Types And Codecs Parameters Used For Audio On The Web
Media File Description Extension Internet Media Type Codecs Parameters
PCM audio in WAV container .wav audio/wav 1
MP3 audio .mp3 audio/mpeg mp3
Vorbis audio in Oga/Ogg container .oga, .ogg audio/ogg vorbis
Low-complexity AAC or AAC+ audio in MP4 container .mp4, .m4a, .aac audio/mp4 mp4a.40.2
CHALLENGE 7.3
What would happen in Figure 7.5 if “sound.aac” can be found but the value of the codecs attribute
does not match its encoding? Also, what would happen if none of the audio files can be loaded?
CHALLENGE 7.4
What types of errors in a code can cause an audio file not to load?
7.4.2.2 <embed>
The <embed> element is used to embed an external application (typically a plug-in) or an interactive
content. Although it is more commonly used to embed video or animation, it can also be used to embed
audio. The attributes that it supports are listed in Table 7.4. Figures 7.6 and 7.7 show how the element is
used and depict the result.
TABLE 7.4
Attributes Used with the <embed> Element
Attribute Function
src Specifies the URL for resource.
type Specifies the Internet media type of source.
width Specifies the length of the displayed content (e.g., media player).
height Specifies the height of the displayed content (e.g., media player).
CHALLENGE 7.5
The width and height attributes on the <embed> element determine how much of the control is
displayed. Experiment with the attributes to see their effects. Also, what are the possible
applications of such flexibility?
In order to specify parameters for the <object> element, the <param> element is used inside it. The
attributes that it supports are name (which specifies the name of parameter) and value (which specifies
the value of the parameter). Figure 7.10 shows how to use the element. The code produces the same result
as Figure 7.9. The only difference is that the audio does not start playing automatically when the page
loads, because the “autoplay” parameter is specified and its value is set to “false.”
FIGURE 7.10 Example usage of the <param> element with the <object> element.
CHALLENGE 7.6
Write a code that combines the <object> and <embed> elements to deliver the same file to see what
happens.
CHALLENGE 7.7
What is the size, in megabytes, of the file generated by a 3-minute mono audio sampled at 22.05 kHz
and 8-bit bit depth?
Although the quality of audio can be described in terms of sampling rate and bit depth, it is bitrate (or
bit-rate) that is usually used to describe it; bitrate is the amount of bits processed, generated, or delivered
per second. Higher sampling rates and bit depths naturally produce higher bitrates. The higher the bitrate,
the higher the quality of an audio. The bitrate for CD, which is a standard for audio quality, for example,
is 1.4 Mbps (i.e., 1.4 megabits per second). How this is derived is shown in the NOTE box.
CHALLENGE 7.8
What is the bitrate of a 22.05 kHz 8-bit audio?
CHALLENGE 7.9
Apart from when music is used as background to a speech, in what situations do you think the use of
multiple sounds might be necessary?
Most modern DAWs are relatively easy and intuitive to use. Where the aim is to produce music, then
some composing talent is necessary; how this is done depends on technique. For example, if all that the
production is going to involve is the use of audio and/or MIDI loops, then only the talent to recognize the
desire loops and combine them creatively is needed, whereas if tracks are going to be created from
scratch, then the talent to compose tunes is certainly more crucial. Loops are short ready-made audio
samples or MIDI patterns that can be used in tracks, instead of recording or creating them from scratch.
The samples could be of anything from guitar riffs to drum parts, and the MIDI patterns are MIDI data
designed to be used to play specific virtual instruments.
Whatever approach is used, producing a musical piece with multiple tracks typically involves creating
the individual audio or MIDI tracks by recording them or by using loops, or both. Where live instruments
are not available, such as in a small studio, the practice is to first create the instrument tracks as MIDI
tracks and then convert them to audio later, when satisfied with them. Typically, the drums are done first,
then the bass guitar, and then everything else one at a time, including vocals. The resulting audio tracks
are then edited and processed, as desired, using audio effects and various types of processing, after which
they are finally mixed down into a stereo (two-track) piece that is ready to be used in an application.
7.5 Video
Video is commonly delivered on a Web page by using hosted video services or adding it to a Web page,
each of which has advantages and disadvantages in terms of the ease with which they can be achieved and
the flexibility that they offer.
CHALLENGE 7.10
Describe a situation in which you would consider linking to a video useful to the user?
CHALLENGE 7.11
In the code, where is the location of the poster image (“garden.jpg”) relative to the HTML file?
Also, where is it best kept and why?
Notice that it is the poster (“garden.jpg”) that is displayed in the example, not the video. The poster can
also be used to display messages to users, such as “Please wait, media downloading ... .” It could also be
a short animation to entertain while the video loads. Other image file formats that are commonly used for
poster include PNG and GIF.
Again, like the <audio> element, the <video> element can be combined with the <source> element to
provide to the browser multiple choices of video file formats and encoding standards. This improves the
chances of a browser finding a file format that it supports and therefore increases the chances of the video
being accessed by as many users as possible. The attributes that it supports are listed in Table 7.8. Figure
7.16 shows how it is used with a code that produces the same result as Figure 7.15.
TABLE 7.8
Attributes Supported by the <source> Element
Attribute Function
src Specifies the URL for the source.
type Specifies the type of the source. It helps the browser determine whether it can play a file before loading it. Value is a string that
identifies a valid Internet media type. Optional codecs parameters can also be added to specify how exactly the source is
encoded.
In the code, the first value of the codecs parameters is the one for the video and the second value is the
one for the audio component. Note that like with the <audio> element, where codecs parameters are
specified, they are one of the values of the type attribute and need to be in double quotes, while all the
values of the attribute are enclosed in single quotes. Again, like with the <audio> element, it is worth
knowing that, although the codecs parameters help the browser decide whether or not it can play a video
file without having to load it first, the downside is that if it is not correctly specified, the browser will
generate an error, even if it can play the file. On the other hand, if the parameters are not specified, the
browser will load the file anyway and discover that it supports the file and play it. The message “Your
Web browser does not support HTML video element” is displayed only if a browser does not support the
<video> element. The formats and codecs that the major browsers support are listed in Table 7.9.
Although H.264 and VP8 now have successors H.265 and VP9, respectively, they are yet to be as widely
supported by browsers as of time of writing.
This means that to ensure your video works with the <video> element, it must be encoded in the codecs
and saved in the file formats. There are several free and cheap video file format converters available on
the Web, including on-line converters, which can be used to convert existing media files to these formats.
A commonly used one designed specifically for converting to HTML5 media formats is Miro Video
Converter.
TABLE 7.9
File Formats and Codecs and Browser Support
Format Supported Codecs Browser Support
MP4 H.264 video + AAC audio Internet Explorer, Firefox, Chrome, Opera, Safari
OGG/OGV Theora video + Vorbis audio Chrome, Firefox, Opera
WebM VP8 video + Vorbis audio Chrome, Opera
CHALLENGE 7.12
Cite some possible problems that embedding a video in a page might cause but linking to it might
not.
7.5.2.2.1.1 Adding Captions and Subtitles The addition of subtitles and captions to videos is worth
mentioning, not least because of its importance to accessibility. The element used to achieve it is the
<track> element. It allows you to specify a timed text track (a file) that is played along a video
delivered using the <video> element. The element is incidentally also used with the <audio> element. The
format of the timed text track supported is WebVTT (Web Video Text Tracks), which carries a .vtt
extension. Figure 7.17 shows an example of the content of a WebVTT file. It says to display the caption
“First caption” at timecode 00:00.000 of the video and remove it at 00.01.980 and so on for the remaining
captions.
Essentially, the browser plays a video and overlays the caption on it but only if the caption or subtitle
function is enabled. This is typically done via the captioning (CC) menu of the media player, which is
usually displayed at the bottom of the window. A WebVTT file can be created using one of the various
tools, including free ones on the Web. An example is HTML5 Video Caption Maker, which allows a
video to be opened in it and automatically inserts start and end time codes for every caption added (either
via typing or via pasting). Before creating a caption file, naturally, a video first needs to be transcribed,
which involves writing down the dialog and commentary in the video and the time codes of where they
start and end.
Table 7.10 lists the attributes supported by the <track> element, and Figure 7.18 shows an example of
how it is used.
TABLE 7.10
Attributes Supported by the <track> Element
Attribute Function
default Enables track if user’s preferences do not indicate to use another track or if no other track is more suitable.
kind Specifies the type of text track. The values supported are keywords: subtitles (which provides translation of content, such as
dialogue and text, and is the default), captions (which provides transcription of audio, including non-verbal sounds), descriptions
(which provides text description of video content), chapters (which provides chapter titles), and metadata (which provides
information that is only visible to scripts).
src Specifies address of WebVTT (.vtt) file and is mandatory.
srclang Specifies the language of text track.
label Specifies title of track and is used by the browser to show available text tracks.
CHALLENGE 7.13
In the code example, what would happen if the <embed> element is placed outside the <object>
element?
When shooting and editing a video, frame size, color depth, and frame rate are some of the properties
that need to be specified. In principle, the higher the values of these properties, the better the quality of
video. The size of the file produced, of course, is also larger. As you might recollect from Chapter 6, a
high-quality bitmapped image produces a relatively large file. Imagine many of this per second, and you
might get a general idea of the file size generated by high-quality digital video. Where there is an audio
accompaniment, this naturally adds to the size.
As an example, a 1-second standard definition (SD) resolution (720 x 576) video digitized at 16-bit
color depth and 25 frames per second, with CD-quality audio accompaniment, can generate as much as
20.91 MB of data. Standard definition resolution is the traditional resolution used in television. More
current definitions include high definition (HD) and ultra-high definition (UHD), which support
resolutions up to 8192 x 4320, both of which support higher resolutions. Whichever standard is used to
encode a video, the amount of data generated is simply more than what Internet connections or systems
can handle speedily. This is why compression is needed even more for the delivery of video than for
other media object types.
Like with audio, the amount of bits generated per second in video is known as bitrate, and the quality
of video is generally defined in these terms. The formula to calculate it is:
Video bitrate = frame size x color depth x frame rate
This means that the bitrate of the example cited earlier is 167 Mbps. To minimize bitrate without
significantly compromising video quality, video compression standards use various techniques, including
reducing the number of bits used to represent the color of the pixels of a frame and using various other
techniques.
CHALLENGE 7.14
Video file size can be calculated by multiplying its bitrate by its duration in seconds. Given this, how
long will it take to download a 1.15 MB video file over a connection that offers an average speed of
2 Mbps?
CHALLENGE 7.15
For which of the following would you use video and for which you would not?
Showing dance moves.
Illustrating how a bicycle pump works.
Sports training.
CHALLENGE 7.16
For which of the following videos would you use high or low frame rates, and why?
Racing
A lecture
A church service
CHALLENGE 7.17
Assume that you are browsing a news website (e.g., CNN) and you click a link because you are
interested in knowing more about the link text. However, when you arrive at the relevant page, a
video is presented that has no direct relevance to the link text and it also starts playing automatically.
Below it is the text form of the actual story described in the link text. What is wrong with this
practice, and how would you fix it?
CHALLENGE 7.18
Again, assume that you are browsing a news website and a video is presented to you, together with
its text equivalent under it. Then, after the video has finished, another video starts, but the article
underneath does not change accordingly, so that the video content no longer matches the article under
it. Say why this is good or bad for user experience, and if you think it is bad, suggest a better design
approach.
If a video capture card is not available but a digital camcorder is available, an analog video can still
be converted. Assuming that the analog video is on a VHS tape, one way in which this is done is to play
the tape in a VCR or an analog camcorder, whose output is connected to the analog input of a digital
camcorder that is set to playback mode, whose digital output is connected to any of the digital ports of a
computer, through where the video is recorded using a video editing program.
When video is being acquired from a digital video device, it is usually only a matter of connecting the
device to the computer via a digital interface, such as IEEE 1394 (Firewire), USB (Universal Serial
Bus), and HDMI (High-Definition Multimedia Interface), and uploading the video to the computer’s hard
disk for editing. Every digital device has at least one of these interfaces and so do most modern
computers or capture cards. Some high-end professional digital camcorders and devices also have SDI
(Serial Digital Interface), a high-capacity connection for exporting uncompressed SD and HD digital
videos in real time, typically in TV broadcasting. Where a digital device uses a removable storage
medium, such as disc or memory card, for which a computer has a drive installed, files can be transferred
directly from it onto the computer’s hard disk.
7.6 Animation
The file format of an animation piece largely determines the types of HTML elements that can be used to
add it to a Web page. The most commonly used file formats include animated GIF, SVG, SWF, and any of
the video file formats previously introduced under video, and these formats are all used to store 2D
animation. A 2D animation is so called because it has only two dimensions (width and height). The other
kind of animation is three-dimensional (3D) animation, which has a third dimension, depth. The use of
3D animation for delivering information is yet to be common on the Web and implemented primarily using
CSS and scripting. The use of CSS for creating 2D and 3D animation is discussed in Chapter 18 and how
HTML and CSS are combined with scripts in Chapter 22.
Animated GIF format is a very old format but still commonly used on the Web for very short repetitive
animations. It is a series of bitmapped images saved in animated GIF file format. Since it is basically an
image file, it is added to a Web page using the <img> element, the element used for adding static images.
Refer to Chapter 6 on how to use the element to add image. Adding animation created using SVG (or even
SVG combined with JavaScript) is done the same way as adding SVG images using the <svg> element,
also introduced in Chapter 6. The SWF format is a Flash file format that is still commonly used for
delivering animation on the Web, although its use is not recommended because the trend is toward making
it obsolete in the future. This is because Flash technology is still a popular tool for creating vector-based
animation. However, using the tool does not mean that what is produced must be saved in SWF. It can be
exported in one of various formats supported by HTML5, such as MP4, WebM, or OGG. Or an SWF file
can be converted to these formats using a free on-line converter. Once in any of these formats, an
animation can be delivered in the same way as a video, using <video>, <object>, or <embed> to embed
it, or <a> to link to it. Figure 7.22 shows how the <object> element is used to embed an animation in a
Web page and Figure 7.23 the result. The animation was created in an old Flash program and converted to
MP4.
In the example, the data attribute specifies the animation to embed and its location (which is the same
as that of the source code), the type attribute specifies the MIME type, and width and height the size. The
name attribute in the <param> element says to loop the animation infinitely.
CHALLENGE 7.19
Implement Figure 7.22 with your own animation, using the <video> and <embed> elements and
experiment with the width and height attributes.
CHALLENGE 7.20
Given that the animation in the example starts automatically and loops forever, modify the code to
make its presentation more user-friendly and say why it is? You can use the <video> element instead
of the <object> element.
7.6.2.3 Coding
It should not be surprising that coding (i.e., computer programming) is another method of creating
animation, since this is what is used to create animation software in the first place. Indeed, most, if not
all, of the advanced animations on the Web and elsewhere, especially fast-action computer games,
involve coding. Naturally, there are different types of coding languages, each suitable for different types
and levels of animation. For the purpose of explanation, they are grouped as general-purpose and Web
coding languages. General-purpose coding languages are powerful and can be used to develop virtually
any type of computer application. A general-purpose language, for example, C++, can be used for any
type of animation. Where advanced animations with a lot of media, fast-moving actions, and high level of
interactivity are involved, it would certainly be one of the main choices.
In contrast, Web coding languages used for animation, which are commonly SVG, CSS, and
JavaScript, are not as powerful as general-purpose coding languages. However, they are increasingly
capable of producing relatively advanced interactive animations. While SVG and CSS can be used only
for relatively basic animations, JavaScript extends the capability, making advanced interactivity possible.
Examples of the types of animation for which SVG and CSS are best-suited include animating the drawing
of objects (including text), interactive maps, morphing of SVG vector objects, and roll-over effect. More
specifically, they are used for the types of animation that seldom perform specific tasks but can enhance
user experience if used appropriately.
8.1 Introduction
Cascading Style Sheets (CSS) is a style sheet language that allows rules to be created that are used to
determine how documents written in a markup language should appear when rendered. In this case, it
allows the properties of the content of HTML elements, such as color, size, and position, to be controlled,
as appropriate. This chapter introduces the fundamental principles of how it works.
FIGURE 8.2 An illustration of the boxes that enclose HTML elements, using a rendered document.
FIGURE 8.4 Structure of the rule for applying the same style to multiple elements.
CSS rules can be declared in a separate document, to which the HTML document to be styled is then
linked, or they can be declared in an HTML document, using the <style> element or the style attribute.
When declared in a <style> element, they are simply placed between the element’s opening and closing
tags. When declared using the style attribute, the declaration block is made the value of the attribute and
placed in quotes, as shown in Figure 8.5.
The declarations in the example say to display the text content of the element on which the style
attribute is in yellow and has Arial family of font. The value of the style attribute is a rule, too, except that
there is no selector, which it does not need, since it is inside an element and applies only to the element.
More about how CSS rules are kept in a separate document or defined within an HTML document is
discussed later in the chapter.
CHALLENGE 8.1
In the .round-edge{} rule in the example in the NOTE box, which is the selector and which are the
declarations and values?
8.3.1.3 Pseudo-Classes
Pseudo-classes are designed to allow elements to be classified on characteristics that are broader than
those possible, for example, with the class attribute. Figure 8.7 shows the format for specifying them, and
Table 8.4 lists them. Note that only a few of them are commonly used. Examples are provided in Chapters
14 and 17.
TABLE 8.4
Pseudo-Classes and Examples of Usage
8.3.1.4 nth Selectors
Instead of the :nth-based selectors listed in Table 8.4 taking just n (i.e., a number), they can also take a
mathematical expression. This enables them to be used to specify multiple child selections, such as every
second or third child element in a list of children of the same parent. The expression’s syntax is an+b, and
it represents an element that has an+b-1 siblings before it in a list of children that share the same parent
with it. For example, if an element has three siblings before it, then its position is 4th and can also be said
to have an index of 4. The index numbering of the children of an element starts at 1 (i.e., the first child has
an index of 1).
Another way to think of the an+b expression is that it selects child elements whose index matches the
value to which the expression evaluates. The value of n can be a positive integer or zero, and the value of
a or b must be a positive or negative integer or zero. Basically, the way it works is that n is progressively
assigned the values of 0,1,2,3, and so on and the expression evaluated each time for each value. In the
end, the element selected is the one with the index that matches the result of the evaluation. So, for the
expression 2n + 1, for example, n is first given the value of 0, which makes the expression evaluate to 1
(i.e., [2 x 0] + 1). So, the first child is selected. Next, n is given the value of 1, which makes the
expression evaluate to 3 (i.e., [2 x 1] + 1). So, the third child element is also selected. In the same way,
the values of 2,3,4, and so on evaluate to 5,7,9, and so on, and the corresponding child elements are
selected, if available. If the expression evaluates to zero or a negative number, no element is selected,
since no child element has a zero or negative index.
To show an example of the application of nth selectors, li:nth-child(4n-7)
{ color: brown; } says to make text brown for all <li> child elements that have the index of 1,5,9, and
so on. This is done by giving n the value of 0, which makes the expression evaluate to -7 (i.e., [4 x 0] - 7),
for which there is no matching element index. Next, n is given 1, which evaluates to -3, for which there is
also no matching index. Next, n is 2, which evaluates to 1, which matches the first child element, and so
on.
Instead of using n or an expression, the odd or even keywords could also be used. The odd keyword
selects child elements 1,3,5,7, and so on, and the even keyword selects child elements 2,4,6,8, and so on.
The odd keyword, for example, can be specified as tr:nth-child(odd){}. It is useful to know that there are
:nth checkers on the Web for trying out outputs of expressions.
CHALLENGE 8.2
Given the following expressions, state the positions of the child elements selected:
1n + 0 (or simply n).
2n + 0 (or simply 2n).
2n + 1.
3n - 4.
n + 5.
-2n + 3.
CHALLENGE 8.3
Which of the following rules has precedence, and what does it do?
p#intro { color=red; } p#intro { color=blue; }
A more accurate way of determining which CSS rule has precedence is to calculate the specificity of
each selector and compare it with the others. This calculation is based on a set of four criteria, designated
as a, b, c, and d. Each occurrence of a criterion in a selector counts as 1 for the criterion. So, if only one
occurrence is found of the “d” criterion in a selector and nothing else, then the selector’s specificity is
0,0,0,1; if one occurrence of the criterion “d,” two occurrences of the criterion “c,” and nothing else are
found, the specificity is 0,0,2,1. Criterion “a” has the most importance, while “d” has the least
importance. In theory, one criterion “a” carries more weight than any number of “b,” “c,” or “d.” The four
criteria and how they are scored are described as follows:
If declarations are made via a style attribute, rather than via a selector, this represents one count
for “a,” so that, the score is a = 1, b = 0, c = 0, d = 0 (or 1,0,0,0).
If declarations are made via id attributes in a selector, the number of such declarations represents
the count for “b.”
If declarations are made via non-id attributes and pseudo-classes in a selector, the number of such
declarations represents the count for “c.”
If declarations are made via element names and pseudo-elements, the number of such declarations
represents the count for “d.”
According to the criteria, the style attribute has the highest specificity, and this is so because its
declarations apply specifically to the element in which it is and to no other. This is followed by the
selector with the highest number of id attributes (because an id attribute is specific to only one element),
then the selector with the highest number of non-id attributes and pseudo-classes, then the selector with
the highest number of element names and pseudo-elements, and then everything else. By applying these
criteria to Figure 8.11, the color of the content of the <p> element will be purple. Table 8.5 shows the
specificity of each selector, which involves examining each selector and counting the number of
occurrences of each of the four criteria.
TABLE 8.5
Explanation of How Specificity Level Is Determined
CHALLENGE 8.4
Using the four criteria presented earlier and Table 8.3 as a guide, determine which of the following
rules has the highest specificity level.
div p { color: red; }
p { color: grey; }
p#blue { color: blue; }
div p.green { color: green; }
8.3.2.3 Inheritance
The inheritance principle relates to whether or not child elements get properties passed on to them by the
parent elements. Basically, some properties are inherited by default, while others are not. Inheritance
determines what happens when no value is specified for a property of an element. When no value is
specified for an inherited property of an element, the element uses the value of the parent element. When
no value is specified for a non-inherited property of an element, the element uses the default value of the
property. The inherit keyword can be used with any property to specify to inherit its value from the parent
element. Figures 8.12 and 8.13 show how this works. The content of the <em> element is blue, like that of
the <p> element, because the color property is an inherited property, which means that its value is
inherited from the parent <p> element. In contrast, the <em> element shows no border even though the
parent <p> element does. This is because the border- style property is a non-inherited property, and the
default value for it on the <em> element is none (i.e., no border). The color property is discussed more
fully in Chapter 9, and the border-style property is discussed in .
CHALLENGE 8.5
Given the HTML and CSS codes below, in which color will the content of the <em> element be
rendered?
CSS
span {color: red; }
p { color: blue }
p { border-style: dotted }
HTML
<h3>Property inheritance</h3>
<p>The color property is an inherited property, so <span><em>the content of the em element</em>
</span> is blue just like that of the parent p...</p>
The principle of inheritance can save a lot of time, as it prevents having to repeatedly write the same set
of rules for child elements that share the same properties. Many properties that are not inherited by default
can be forced to inherit values from their parent elements by using inherit as the value for the relevant
properties. Figures 8.14-8.16 illustrate this with two <div> elements, which are children of the <body>
element.
In the example, the properties specified in the body{} rule (i.e., font-family, color, padding, and
margin) are inherited by the two <div> elements, except padding and margin, which are non-inherited by
default. The properties specified in the div.partl{} rule (i.e., border and background-color) apply to only
the first <div> element, and those specified in the div.part2{} rule apply to only the second <div>
element. The second <div> element also inherits the non-inherited padding and margin properties of the
<body> element, because it is forced to do so with the use of the inherit keyword as value. Again, all the
various properties are used here only to explain inheritance and are discussed more fully in later
chapters. The font-family is discussed in Chapter 13; color and background-color are discussed in
Chapter 9; and border, padding, and margin are discussed in .
FIGURE 8.14 HTML for demonstrating CSS inheritance principle.
FIGURE 8.15 CSS used with Figure 8.14 for demonstrating inheritance principle.
CHALLENGE 8.6
Rewrite the CSS code in Figure 8.15 to make it more efficient.
CHALLENGE 8.7
Implement the example, but also use one of the inline elements discussed under HTML in Part 1 to
isolate a few words for styling that are different from that of the rest of the text.
The inline CSS method is not recommended for any serious use. This is because it is limiting and
inefficient, in that it can only be used by one document. For example, if another document requires exactly
the same CSS styling as the one used in one document, the same CSS has to be repeated for it. This can be
especially timeconsuming and costly if a number of rules are involved. Not only that, maintenance can be
unnecessarily unwieldy. So, in essence, inline should really only be used for the purpose of quick styling,
such as for prototyping purposes, and, like with {important exception, for page-specific CSS designed to
override some site-wide or global styles.
8.3.3.1.2.1 Using the scoped Attribute The scoped attribute, when used on the <style> element, allows
styles to be applied to only an element and its children and overrides previously set styles. The <style>
element is placed inside the target element. Figure 8.20 shows how the attribute is used, and Figure 8.21
depicts the result.
CHALLENGE 8.9
Can you think of why the use of the scoped attribute is necessary when you can use the class or id
attribute to target an element?
FIGURE 8.22 HTML document linked to the external CSS in Figure 8.21.
CHALLENGE 8.10
In the example in Figures 8.22 and 8.23, what is the location of the style sheet in relation to the
HTML document that references it?
The example provides three style sheets (default.css, basic.css, and classy.css). Notice that in the
<link> elements for the alternative style sheets, the rel attributes each has a space-separated list of values:
“alternative stylesheet.” It must be in this way in order for an alternative style sheet to be specified. Also,
the title attribute must be used, and it must not be empty. Its value is what is listed as a style option for
users to choose under the style sub-menu of the View menu of some browsers. When a user chooses an
alternative style sheet, the page is immediately rendered using the style. Style sheets that have the same
value for the title attribute are treated as part of the same style option.
CHALLENGE 8.11
Implement the example in Figure 8.25, using different style sheets, to see how the concept of
alternative style sheets works.
9.1 Introduction
Color is an essential element of Web design, in that it is capable of communicating the emotions of users.
As a result, it is one of the design tools available to Web authors for creating the intended first impression
for a website. This chapter introduces the CSS properties used to specify color and also discusses design
guidelines and practices for the effective use of CSS.
CHALLENGE 9.1
The default color for a Web page is white. How do you specify a different color?
CHALLENGE 9.2
What do the codes below produce, and why?
CSS
#square1 { background-color:rgb(255,0,0); } #square2 { background-color:rgba(0,255,0,0.75); }
#square3 { background-color: rgba (0,0,255,0.25); }
HTML
<div id=“square1”></div>
<div id=“square2”></div>
<div id=“square3”></div>
FIGURE 9.4 A demonstration of the effects of the use of transparency with a color.
CHALLENGE 9.3
What are the ways to add transparency to the following CSS rule: p{ background-color:
hsl(240,100%,50%); }?
The RGB model is capable of producing most of the colors visible to humans, and when each color is
represented with 8 bits (i.e., 24 bits for all red, green, and blue together), up to 16,777,216 (i.e., 224)
different colors can be produced. Representing red, green, and blue, each with 8 bits, means that 256 (i.e.,
28) different shades of each can be produced and specified on a 0-255 scale. Recall from Chapter 6 that
the number of bits used to represent a color is bit depth or color depth.
There are also other color models, such as YUV used by camcorders for encoding video and CMYK
used by printers, but RGB is the only one relevant to CSS. The RGB model is the most important color
model in computer application development, since most of the interaction with an application happens on
the screen. Although it is suitable for describing color in terms of primaries and human perception of
colors, it is not suitable for describing how humans describe color. Indeed, it is seldom obvious to most
people that a color contains red, green, or blue, and we hardly know what proportions of these colors
make up a color when we look at it; rather, we see a color in terms of a variation of a hue and describe it
in the same way. For example, we might say “a shade of red,” “deep green,” and “light blue.” In other
words, we tend to describe colors in terms of the hue, intensity of the hue, and its lightness or darkness.
The aim of the alternatives to the RGB color model is to model color in terms of these properties. The
most common of these alternatives are HSL and HSV.
You have already encountered HSL earlier. HSV stands for hue, saturation, and value (lightness),
which is also described in some visual-media-editing applications as HSB (hue, saturation, and
brightness) or HSI (hue, saturation, and intensity). Only HSL is supported by CSS. Figure 9.6 shows a
representation of the model. 07360° hue is red; 120° hue is green; and 240° hue is blue. In loose terms,
hue is the same as pure color. Saturation is the amount of gray in a color. At 0%, the amount of gray is at
maximum (100%), while the amount of hue is 0%, making the color to be displayed as gray. Lightness (or
value) is the amount of white or black in a color. At 0%, the amount of black is at maximum (100%),
resulting in a black color, and at 100%, the amount of white is maximum, resulting in white. At 50%, the
amounts of white and black are normal, which means that saturation is also at 100%, meaning that a pure
color is displayed.
The colors resulting from adding white to a color are usually referred to as tints; the colors resulting
from adding gray to a color are referred to as tones; and the colors resulting from adding black to a color
are referred to as shades. Figure 9.7 illustrates this.
CHALLENGE 9.4
To better understand the HSL or HSB color model, create a shape in your Microsoft Word, or any
other application that allows you to do this, and fill the shape with a primary color, such as red.
Then, open the color picker and manipulate the values for saturation and lightness (or brightness).
If these color pickers are not of adequate use, there are many free online color converters that allow the
conversion of a color value from one model to another. They also allow color names to be specified, and
they work on a similar principle as the one in Figure 9.8.
The colors of a color wheel are generally grouped into cool, warm, and cool and warm, as illustrated
in Figure 9.11. Cool colors include greens, blue-greens, and blues; warm colors include yellows,
oranges, and reds; and purples are either cool or warm. Black is considered warm, because it absorbs all
colors and reflects none, while white is considered cool, because it absorbs no colors and reflects
everything. Warm colors are used to project warmth in a design, while cool colors are used to project
coolness.
By combining the colors in a color wheel, using various configurations, it is possible to produce
different types of color schemes, both basic and complex, each of which is best suited for different
situations. The color schemes presented here include monochromatic, analogous, complementary, split
complementary, double contrast, and triadic. However, there are others. One is the neutral scheme,
which includes neutral colors, such as white, black, gray, beige, and brown, which are colors not found
on the color wheel. Another is accented neutral scheme, which includes neutral colors and small
amounts of one or more colors from the color wheel; for example, black and gray may be used with red.
Some websites provide dynamic color scheme generators with which to experiment, as a quick
search should reveal. Some popular ones include paletton.com and color.adobe.com. The latter website
also supports the use of images for generating a color scheme. Basically, it allows an image to be
uploaded and uses the colors in it to compose a color scheme with which you can then experiment. Being
able to generate a color scheme from an image is particularly useful when a design is being created
around a central image, such as a logo and the image of nature.
9.5.1.1 Monochromatic
This is a relatively basic scheme that uses only one color, as implied in the name (“mono” meaning one
and “chroma” meaning color). Although only one hue is used, the use of tints and shades of the same color
makes it possible to produce interesting designs. The scheme is easy to work with and usually produces
designs that look balanced and appealing. What constitutes balance in design is discussed in Chapter 23.
The main downside of the scheme is that it is difficult to achieve strong contrast or vibrant designs with it.
Figure 9.12 shows an example of a design that uses green and its tints and shades. The color palette
shows the main colors used in the design, but they are only some of the colors that can be derived from
green via the scheme.
FIGURE 9.12 A screenshot of a design that uses monochromatic color scheme, the palette of the colors used, and the configuration on the
wheel (decembermarketing.com).
CHALLENGE 9.5
For which of the following types of websites would you use the monochromatic color scheme? Also,
how would you use the scheme? For example, what color would you use for background, header,
footer, text, aside, and so on?
A kids’ website.
A marketing company.
A stock market website.
An e-commerce website.
A university website.
CHALLENGE 9.6
Picking a base color other than the one used in the example, choose two types of websites from the
list above and create a design for each by using the color and the monochromatic color scheme.
9.5.1.2 Analogous
The analogous scheme, too, is a basic scheme, and it uses colors that are next to each other on the color
wheel. Typically, three to five colors are used, but more colors may also be used. Designs produced using
the scheme are richer than those produced with monochromatic scheme. However, the scheme, too, lacks
contrast because of the relatively close similarities between adjacent colors on the wheel. Variation of the
scheme are the warm scheme, which uses only warm colors, such as reds, yellows, and oranges, and the
cool scheme, which uses only cool colors, such as blues, greens, and purples. Figure 9.13 shows an
example of a design that uses the analogous scheme of warm colors. The circular “Award” image at
bottom right is not part of the design, so its colors are not part of the scheme; however, the blue
provides a good accent. When using this scheme, attention needs to be paid to the contrast between text
and background colors to ensure good level of legibility. If the colors are too close, tints and shades are
usually used to improve contrast.
FIGURE 9.13 A screenshot of a design that uses analogous color scheme, the palette of the colors used, and the configuration on the wheel
(http://www.itcatmedia.com/school).
CHALLENGE 9.7
For which of the following types of websites would you use the analogous color scheme? Also, how
would you use the scheme? For example, what color would you use for background, header, footer,
text, aside, and so on?
A kids’ website.
A marketing company.
A stock market website.
An e-commerce website.
A university website.
CHALLENGE 9.8
Picking a base color other than the one used in the example, choose two types of websites from the
list above and create a design for each by using the color and the analogous color scheme.
9.5.1.3 Complementary
The complementary scheme uses colors that are opposite to each other on the color wheel, such as red
and green. The high contrast that results from combining complementary colors typically creates a vibrant
look, particularly when the colors are highly saturated. However, combining highly saturated colors can
also produce unwanted optical effects, such as vibrations, shadows, and afterimages (ghost images),
particularly when they touch. Figure 9.14 shows an example of a design in complementary colors.
To avoid unwanted optical effects when using complementary colors, neutral colors may be added,
particularly as background colors, such as the ones shown in Figure 9.15. Notice how the text in the left
illustration is difficult to read, while it is not so in the right illustration, because white background is
used.
FIGURE 9.14 A screenshot of a design that uses complementary color, the palette of the colors used, and the configuration on the wheel.
FIGURE 9.15 Complementary colors (left), and with a neutral color as background (right).
CHALLENGE 9.9
For which of the following types of websites would you use the complementary color scheme? Also,
how would you use the scheme? For example, what color would you use for background, header,
footer, text, aside, and so on?
A kids’ website.
A marketing company.
A stock market website.
An e-commerce website.
A university website.
CHALLENGE 9.10
Picking a base color other than the one used in the example, choose two types of websites from the
list above and create a design for each by using the color and the complementary color scheme.
FIGURE 9.16 A screenshot of a design that uses split complementary color, the palette of the colors used, and the configuration on the
wheel.
CHALLENGE 9.11
For which of the following types of websites would you use the split complementary color scheme?
Also, how would you use the scheme? For example, what color would you use for background,
header, footer, text, aside, and so on?
A kids’ website.
A marketing company.
A stock market website.
An e-commerce website.
A university website.
CHALLENGE 9.12
Picking a base color other than the one used in the example, choose two types of websites from the
list above and create a design for each by using the color and the split complementary color scheme.
FIGURE 9.17 A screenshot of a design that uses double-contrast colors, the palette of the colors used, and the configuration on the wheel.
FIGURE 9.18 A variation of the double-contrast color scheme.
CHALLENGE 9.13
For which of the following types of websites would you use the double-contrast color scheme? Also,
how would you use the scheme? For example, what color would you use for background, header,
footer, text, aside, and so on?
A kids’ website.
A marketing company.
A stock market website.
An e-commerce website.
A university website.
CHALLENGE 9.14
Picking a base color other than the one used in the example, choose two types of websites from the
list above and create a design for each by using the color and the double-contrast color scheme.
9.5.1.6 Triadic
The triadic scheme involves three colors that are equidistant from each other on the color wheel, such as
red, yellow, and blue. Although it is not as contrasting as the complementary scheme, it, too, produces
strong vibrant designs, and it is relatively easy to achieve balance and harmony with it. Figure 9.19 shows
a design that uses triadic colors and their tints and shades.
FIGURE 9.19 A screenshot of a design that uses triadic colors, the palette of the colors used, and the configuration on the wheel
CHALLENGE 9.15
For which of the following types of websites would you use the triadic color scheme? Also, how
would you use the scheme? For example, what color would you use for background, header, footer,
text, aside, and so on?
A kids’ website.
A marketing company.
A stock market website.
An e-commerce website.
A university website.
CHALLENGE 9.16
Picking a base color other than the one used in the example, choose two types of websites from the
list above and create a design for each by using the color and the triadic color scheme.
CHALLENGE 9.17
Visit color.adobe.com, if you have not already done so, and experiment with the color schemes that it
offers. Also, create a color scheme by uploading an image, and experiment on the color scheme
generated.
9.5.2 Color Proportions
While color schemes provide guidelines on the colors to combine, they do not provide information on
how much to use. Although there are no steadfast rules regarding this, there are common practices. A
basic rule of thumb is the 60-30-10 rule, which is traditionally applied in interior design to produce
professional quality color decoration for a space. In Web design, the space is the screen or page. The rule
recommends that it should be filled in the following proportions:
60% in the dominant color. This is the background, and typically used colors are light neutral
colors (e.g., gray, black, and brown) or tints of a hue.
30% in the subdominant (or secondary) color, which is typically a stronger color than the
background.
10% in the accent color, which is typically a vivid color and is commonly used to direct users’
attention to an important feature, such as a call-to-action button, for example, a “Register” button.
You may also encounter these three components being referred to by different names in Web design. For
example, dominant color may be described as base or subdominant color, secondary color as dominant,
and accent color as highlight, but the general concept of 60-30-10 still applies. However, the 60-30-10
proportion is not cast in stones; it can be varied slightly, as long as the 100% total is maintained.
Examples include 65-25-10 and 60-29-11. More than three colors can also be used, again, as long as the
100% total is maintained. When more than three colors are used, it is usually by adding more secondary
colors, in which case, the total space occupied should not be more than the 30% proportion for the
secondary color. The tints, tones, or shades of the secondary color or other colors may be used, based on
the relevant color scheme. The total number of colors is normally best kept at five plus/minus two colors,
as too many colors can make it difficult for the user to build a mental picture of a page and understand
how to interact with it. Consistency in the use of colors across pages, naturally, contributes to the
building of a mental picture of a website.
CHALLENGE 9.18
What should be the proportion of the color used for accenting? Also, which of the following colors
would you use for accenting, and why?
CHALLENGE 9.19
For which of the following would you use variations of the same color and for which would you use
different colors to aid organization?
Categories of news items.
Columns of a table.
Series of recorded weights, with each weight indicating whether it is up or down compared
with the previous and next ones.
CHALLENGE 9.20
What in how colors are used contribute to a website’s aesthetics? Also, is just using the right color
scheme enough to achieve aesthetics? If no, say what else should be done. If yes, give reasons for
your answer.
CHALLENGE 9.21
Which elements of a website are likely to have properties and behavior that can cause photic
stimulation?
TABLE 9.1
Common Colors and Their Associations
Source: Adapted from Jill Morton.
CHALLENGE 9.22
Using the information in Table 9.1 as a guide, state which colors you would use for the following
types of websites and also justify your choices.
A bank
Luxury products
Sports
Hospital
Church
CHALLENGE 9.23
Perform a Web search for “kids websites” to see examples of the use of colors when children are the
target. Also, see if you can recognize any color schemes.
CHALLENGE 9.24
In which of the following cases is it necessary to provide a text explanation of the use of color or an
annotation for the benefit of color-blind or blind users? Also, give reasons for your answer.
The color scheme used on a page.
The image of a T-shirt on sale.
The color of call-to-action buttons.
A color railway network map.
A color swatch used to pick a color for the required item on a site.
A pie or bar chart.
10.1 Introduction
The concept of CSS box model was introduced in Chapter 8. The concept says that every element in an
HTML document is represented with a rectangular box, whose properties, such as width, height, border,
padding, and margin, can be controlled to help determine the design of a Web page. This chapter presents
the CSS properties used to achieve this.
CHALLENGE 10.1
Modify the code in Figure 10.1, as necessary, to produce the output below:
CHALLENGE 10.2
In the example, what would block-size and inline-size define if writing mode is from top to bottom
and right to left?
10.3.2.1.1 overflow
The overflow property, which is non-inherited, specifies what to do with the content that overflows the
borders of a box container or table cells. The common keyword values that it takes and their functions are
listed in Table 10.1.
Figure 10.7 shows the addition of the overflow property to the rules shown earlier in Figure 10.5, and
Figure 10.8 shows the effects. Notice that the browser sees it fit to add scrollbars.
TABLE 10.1
The Values Supported by the overflow Property
Value Function
visible Does not clip overflow, and the rendered content overflows the element’s box if too large for the box.
hidden Clips overflow and makes the rest of content invisible or unavailable.
scroll Clips overflow and provides a scrollbar to scroll to the rest of the content.
auto Lets the user agent (e.g., browser) to decide on the best solution.
FIGURE 10.8 The result of Figure 10.5, with the overflow property added to the rules, as shown in Figure 10.7.
CHALLENGE 10.3
Use the visible, hidden, and scroll values with the overflow property to see their effects. Notice
especially the difference between scroll and auto by resizing the width of the browser.
CHALLENGE 10.4
The two rules in Figure 10.7 are identical. Implement Figure 10.5, substituting the rules, and then
modify the whole code to remove repetitions and to make it more efficient.
10.3.2.1.2 white-space
The white-space property is inherited and allows you to control how white space inside an element is
handled. The values that it supports are listed in Table 10.2.
Figure 10.9 shows how the property is used, and Figure 10.10 depicts the result. Notice in the code that
there is white space between the starting <p> tags and where the content starts. Then, notice how the
value used with each white-space property determines how the space is handled when the contents are
displayed.
TABLE 10.2
The Value Supported by the white-space Property
Value Function
normal Specifies to collapse sequences of white space. Wraps text.
nowrap Specifies to collapse white space as normal but ignores line breaks. Does not wrap.
pre Specifies to preserve sequences of white space and break lines at new-line characters or <br> elements. Does not wrap.
pre- Specifies to preserve sequences of white space and break lines at new-line characters or <br> elements and, as necessary, to fill box.
wrap Wraps text.
pre-line Specifies to collapse sequences of white space and break lines at new-line characters or <br> elements and, as necessary, to fill box.
Wraps text.
CHALLENGE 10.5
Given the CSS rule, .normal { white-space: normal; }, what is the rendered output for the following?
<p class=“normal”>
Phasellus sagittis, ipsum sed laoreet fermentum, lacus ...
</p>
10.3.2.1.3 text-overflow
The text-overflow property is non-inherited and is used to specify how the browser should communicate
to the user that there is content overflow that is not displayed. It applies to content that is overflowing
only the side of a container box, not the bottom. Text can overflow when it is stopped from wrapping, for
example, due to the use of white-space: nowrap declaration or a word being too long. The property does
not make overflow to occur by itself. So, for it to have an effect, properties that cause overflow, such as
the overflow property, must first be applied to an element. The typical values used with the property are
described in Table 10.3. Figures 10.11 and 10.12 show how it is used and depict the effect.
In the rule, the white-space: nowrap; declaration says not to wrap the text. This means that when the
text reaches the border, it is clipped. The overflow: hidden; declaration hides the overflow, and text-
overflow: ellipsis; adds ellipsis, as shown in Figure 10.12, to show that the text is clipped.
TABLE 10.3
Values Supported by the text-overflow Property
Value Function
clip Specifies to clip text at the border of the box. The clipping can occur in the middle of a character but can be made to occur between
characters if the empty string value ‘ ‘ is used. It is the default.
ellipsis Specifies to display an ellipsis (‘...’) to indicate that text has been clipped. If there is not enough space, the ellipsis is clipped.
<string> Specifies a custom string (e.g., ‘***’ and ‘-’) to use to indicated that text is clipped.
FIGURE 10.11 Handling horizontal overflow.
CHALLENGE 10.6
Implement the example and experiment with the values of the properties to see their effects.
10.3.2.1.4 overflow-wrap
The overflow-wrap allows you to specify whether or not the browser should break text lines in the
middle of words to prevent them from overflowing the right or left edge of an element’s box. The element
was originally known as word-wrap and is inherited. As of time of writing, only Chrome and Opera
support the new name. The values that the property takes are normal (which means to break lines at
normal word breakpoints) and break-word (which means that lines may be broken in the middle of
words). Figures 10.13 and 10.14 shows how the property is used and depict the result.
CHALLENGE 10.7
In the example, why is it necessary to specify width for the elements to demonstrate the overflow-
wrap property?
FIGURE 10.13 Example usage of the overflow-wrap property.
The word-break property, which is also inherited, performs similar functions as overflow-wrap, except
that it is more suitable for where text contains multiple languages, especially CJK (Chinese, Japanese,
and Korean). The values supported are normal (which means to use default line break rule), break-all
(which means to allow word breaks for non-CJK text), and keep-all (which disallows word breaks for
CJK text and behaves as normal for non-CJK text).
CHALLENGE 10.8
Implement the example in Figure 10.13 by using word-break and its values, instead of overflow-
wrap, to see the difference between the two.
10.3.2.1.5 hyphens
The hyphens property allows you to specify how to hyphenate words when text is wrapped. It is
inherited, and Table 10.4 lists the values that are supported. Figures 10.15 and 10.16 show how it is used
and depict the result.
In the example, the p.none{} rule says to wrap text, based on white space. The p.manual{} rule says to
break the word “demonstrates” where the soft (invisible) hyphen character is inserted. Note that the soft
hyphen can also be specified using its Unicode (thus: ). The p.auto{} rule says that the browser should
decide.
TABLE 10.4
Values Supported by the hyphens Property
Value Function
none Wraps text only at white space.
manualWraps only where the characters in a word suggest it. You can suggest breakpoints by inserting in a word one of the two Unicode
characters, U+2010 (hard hyphen) and U+00AD (soft hyphen), which can be specified in HTML as ‐ and ­,
respectively. How to specify special characters is explained in Chapter 3. The hard hyphen is rendered even if word is not broken,
while the soft hyphen is rendered only if break is broken.
auto Browser determines where to break words.
CHALLENGE 10.9
Implement the example in Figure 10.15 separately for each value, using a lot of text and a wider
width, to get a good sense of how the property works. Also, use the hard hyphen (i.e., ‐)
where wrapping is not necessary, in order to see the effect. If the property does not work well in a
browser, try using the vendor prefixes, as shown in Chapter 8.
10.3.2.2 Specifying Minimum and Maximum Logical Width and Height
The properties used to specify the logical minimum and maximum width and height of an element are min-
block-size, min-inline-size, max-block- size, and max-inline-size, and whether each defines minimum or
maximum width or height depends on the value of the writing-mode property (discussed in Chapter 14).
They are non-inherited and take the same values as the min-width, min-height, max-width, and max-
height properties introduced earlier; however, keyword values, such as none, min-content, max-content,
fit- content, and fill-content, may also be supported in the finalized specification. Figure 10.17 shows how
the properties are used.
FIGURE 10.17 Example usage of properties for specifying the minimum and maximum logical width and height of an element.
In the example, given the value of writing-mode (which is in right-to-left, top-to- bottom text-flow
direction), min-block-size defines minimum height, max-block- size defined maximum height, min-inline-
size defined minimum width, and max-inline-size defined maximum width. The example produces the
same result as specifying min-height: 300px; max-height: 900px; min-width: 400px; max-width: 1200px;,
but if writing mode is changed, a different result is produced.
CHALLENGE 10.10
In the example, what would min-block-size, max-block-size, min- inline-size, and max-inline-size
define if writing mode is from top to bottom and left to right?
10.3.3 calc()
As mentioned in Chapter 6, the calc() function allows you to tell the browser to calculate values
dynamically and can be used with any CSS numeric values, such as length, angle, time, and integer. It
especially makes it easy to position elements symmetrically in a container, such as in the middle. It takes a
mathematical expression that evaluates to the value used for a property. The expression combines
operators such as +, -, *, and /, which specify addition, subtraction, multiplication, and division,
respectively. Figure 10.18 shows how the function is used, and Figure 10.19 depicts the result.
FIGURE 10.18 Example usage of the calc() function.
In the example, the rules say to make the widths of the <div> elements as the width of the browser
minus 90px and 200px, respectively. The browser-width percentages can also be specified using the vw
(viewport width) unit, introduced in Chapter 6, under responsive images. So, for example, the CSS
declaration min-width: calc(50vw- 10 0px) specifies that whatever be the width of the viewport, the
minimum width (min-width) of the element to which the declaration is applied should be 50% of it minus
100px. Using it in center-aligning an element requires the use of other CSS properties, especially margin,
which is discussed in the next section.
CHALLENGE 10.11
Place a <div> element inside another <div> element and use the calc() function to make the width of
the inner <div> element half of the outer one and the width of the outer one-three quarters that of the
viewport.
10.4.1 Border
The appearance of an element’s border, which is described mainly in terms of line style, color, and line
width, can be specified in different ways by using longhand and shorthand properties. There are:
Longhand properties for specifying line style, color, or line width for a specific border edge, for
example, border-top-style.
Shorthand properties for specifying line style, color, or line width for all or a combination of
border simultaneously, for example, border-style.
Shorthand properties for specifying line style, color, and line width for a specific border edge
simultaneously, for example, border-top.
Shorthand property, border, for specifying line style, color, and line width simultaneously.
In addition to properties for setting line style, color, and line width, there are those for specifying images
and radius to use for a border, all of which are available in longhand and shorthand. It is worth knowing
that for the border of a box and the changes made to it to be visible, the line style must be specified.
This is because the browser displays no border for an element by default. Note that border properties, in
general, can also be used for table’s <th> and <td> elements. How this is done is shown under the styling
of tables in Chapter 17.
10.4.1.1 border-style
The border-style property is a shorthand property for specifying the line style for all the four edges of an
element’s border. It is non-inherited, and the values that it supports are listed in Table 10.5. Figures
10.20 and 10.21 show how the property is used and depict the result.
TABLE 10.5
The Values Supported by the border-style Property
FIGURE 10.20 Example usage of the border-style property.
FIGURE 10.21 The rendered result of Figure 10.20.
Figure 10.22 shows how a list of space-separated values may be specified, so that different edges are
given different styles, without using the longhand border-style properties. Figure 10.23 shows the
rendered result. How the values are assigned to the edges is listed in Table 10.6.
TABLE 10.6
How the Values of the Shorthand border-style Property Are Assigned
Number of Values Application of Values
One Value is assigned to all four edges.
Two First value is assigned to top and bottom, and second value is assigned to right and left.
Three First value is assigned to top, second to right and left, and third to bottom.
Four First value is assigned to top, second to right, third to bottom, and fourth to left.
CHALLENGE 10.12
Write the code to produce something similar to the following:
10.4.1.1.1 Longhand border-style
The longhand versions of the border-style property are border-top-style, border-right-style, border-
bottom-style, and border-left-style; these are used to apply style to the top, right, bottom, and left edges,
respectively. Like the shorthand, they are non-inherited. Figure 10.24 shows how they are used, and
Figure 10.25 shows the result.
CHALLENGE 10.13
In the code in Figure 10.24, what would happen if the <p> element contains no content, and what is
the reason for this?
CHALLENGE 10.14
Again, in relation to Figure 10.24, if you do not want any content in the <p> element but want it to be
as if it has content by putting space in it, how would you do this?
CHALLENGE 10.15
Implement the example and experiment with the value of the border-block- start-style attribute.
10.4.1.2 border-width
The border-width property is a shorthand property for specifying the thickness of the border of an
element’s box. The longhand properties are border-top-width, border-right-width, border-bottom-width,
and border-left-width, and the values supported by the properties are non-negative length values (e.g.,
pixels, em, rem, and cm) and keywords (e.g., thin, medium, and thick). The properties are non-inherited.
Figures 10.28 and 10.29 show how they are used with various combinations of values and depict the
rendered result. Table 10.7 shows how the values are assigned to produce the result.
TABLE 10.7
How the Values of the Shorthand border-width Property Are Assigned
Number of Values Application of Values
One Value is assigned to all four edges.
Two First value is assigned to top and bottom, and second value is assigned to right and left.
Three First value is assigned to top, second to right and left, and third to bottom.
Four First value is assigned to top, second to right, third to bottom, and fourth to left.
CHALLENGE 10.16
Using the example in Figure 10.24 as guide, write a code by using longhand properties to specify the
width for each of the four edges of a <div> element separately.
CHALLENGE 10.17
Using the example in Figure 10.28, write a code by using the shorthand border- width property to
specify the width for the four edges of a <div> element, making the right and left edges the same and
the top and bottom edges different.
CHALLENGE 10.18
In the example in Figure 10.28, why is it necessary to specify the border-style property?
CHALLENGE 10.19
Implement the example and experiment with the value of the border-block- start-width attribute.
10.4.1.3 border-color
The border-color property is a shorthand property used to specify the color of the four edges of an
element’s border. Like other border properties, it has longhand versions for specifying colors of
individual edges, which are border-top-color, border- right-color, border-bottom-color, and border-left-
color, all of which are non-inherited. The values that they support are color names and color values in
decimal and hexadecimal numbers, and the alpha channel (i.e., rgba and hsla) is supported. See Chapter
9 for more on the syntax used for specifying color. Figure 10.32 shows how the property is used with
various types of values, and Figure 10.33 shows the rendered result. Table 10.8 again lists how the
border-color property values are assigned.
TABLE 10.8
How the Values of the Shorthand border-color Property Are Assigned
Number of Values Application of Values
One Value is assigned to all four edges.
Two First value is assigned to top and bottom, and second value is assigned to right and left.
Three First value is assigned to top, second to right and left, and third to bottom.
Four First value is assigned to top, second to right, third to bottom, and fourth to left.
CHALLENGE 10.20
Implement the code in Figure 10.32 by using the <div> element and also apply background color.
How to apply color has been dealt with in Chapter 9.
FIGURE 10.34 Example usage of properties for specifying color for logical border.
FIGURE 10.35 The result of Figure 10.34.
CHALLENGE 10.21
Implement the example and try the rest of the properties for applying color to logical border edges.
FIGURE 10.36 Example usage of shorthand properties for defining border edge.
In the example, the .one{} rule makes the top border edge 2px thick, dashed, and red. In the .two{}
rule, the color value is omitted, so the default, black, is used. In the .three{} rule, no style is specified, so
the border is not displayed.
CHALLENGE 10.22
What will the rule .three { border-bottom: red; } produce with the HTML code in Figure 10.36?
Also, what will the rule .one { border-top: dashed red 2px; } in the example produce if 2px comes
before red?
FIGURE 10.38 Example usage of properties for specifying logical border edges.
CHALLENGE 10.23
Implement the example in Figure 10.38 and try the rest of the properties for specifying logical border
edges to see the effects. Also, what line style will be displayed if the “dashed” value is omitted in
the example, and why? Also, what will happen if the order of the values is changed?
10.4.1.5 border
The border property is a non-inherited shorthand property that allows you to specify border-width,
border-style, and border-color properties in one go with one rule. However, only one value is allowed
for each of these properties, meaning that the same value is applied to all four edges of a box. Figure
10.40 shows examples of how it is used, and Figure 10.41 depicts the rendered result.
The values must be specified in the specific order shown in the example (i.e., border-width, border-
style, and border-color). If one value is missing, the initial (default) value for the property is used. For
example, the border for the first <p> element is not shown because no border-style is specified in the
corresponding rule (i.e., p.one { border: thick; }) and initial value is none. The border-color property is
also not specified. Although the initial value is black, it does not show, because the value of border-style
is none. In the second <p> element, border-color is not specified, so the initial value, black, is used.
CHALLENGE 10.24
In the example, the reason why the border is not shown for the first <p> element in Figure 10.41 is
because the p.one{} rule in Figure 10.40 is not written properly. True or false? Give reasons for
your answer.
10.4.1.6 border-image
The border-image property is non-inherited and is a shorthand property for specifying the image to be
used to style the border of a box, instead of the line styles provided by the CSS border-style property. The
values supported by the property specify the image to use, where to place the slice lines to divide up the
image, and how to display the sliced pieces. Figure 10.42 shows the image used here to demonstrate how
the property works. It is 90px x 90px in dimension and is designed so that it is straightforward to
determine the location of the slicing lines. The lines are specified in terms of how far in from the top,
right, bottom, and left edges of the image to place them (i.e., where to slice the image). The image was
created in Photoshop but can be created in any graphics program and should be in a standard image file
format (e.g., jpeg, png, and gif).
Figure 10.43 shows how Figure 10.42 is used with the border-image property, and Figure 10.44
depicts the result. In the example, the border-style property is set to a visible style to allow the image to
show, and the border- width property is set to a value that is large enough to let it show at the required
size. The p{} rule specifies the properties common to the two <p> elements. The border-image property
values in the p.round{} rule say to use the image in
Figure 10.42 (called “star_oval.png”) for the border of the first <p> element. It says to slice it at 30px
in from the top, right, bottom, and left edges, respectively, and repeat and scale the edge pieces (i.e., the
ovals) as necessary. The corner pieces are always placed at the corners, as they are. The values of
border-image property in the p.stretch{} rule say the same thing for the border of the second <p> element,
except to stretch the edge pieces. Note that the border-image property may need to be repeated with
vendor prefixes for older browsers. This is because the property is one of those implemented differently
in browsers, especially in older ones. You will find more on vendor prefixes in Chapter 8.
You would have noticed that the middle piece of the image in Figure 10.42 is not used.
In order to use it, the longhand versions of the border-image property usually need to be used. Note that
these longhand properties can also be used to achieve the same goal as Figure 10.44. Table 10.10 lists
them and their functions.
CHALLENGE 10.25
Create an image in a graphics program of your choice, following the guidelines already given, and
then use the image to implement the example in Figure 10.43. Also, experiment with the slice values
to see the effects.
TABLE 10.10
Longhand border-image Properties
CHALLENGE 10.26
How would you rewrite the code in Figure 10.43, using the longhand border- image properties
described in Table 10.10?
Figure 10.45 shows how the middle piece of a sliced image is used, and Figure 10.46 shows the result.
The p{} rule specifies the properties that are common to the two <p> elements. The border-image-source
and border-image-slice properties work as described earlier in Table 10.6, and the fill value says to use
the middle image piece as background. Notice that it is specified in place of the value for the top edge of
the box. The p.round{} rule says to repeat the edge-image pieces for all the edges of the border and the
middle piece for the background. The p.stretch{} rule says not to repeat but stretch them.
FIGURE 10.45 How border-image-slice property is used to apply the middle image piece.
FIGURE 10.46 The result of Figure 10.45.
CHALLENGE 10.27
What is the obvious problem posed to the user by the rendered result in Figure 10.46 in relation to
the use of image as background, and how can you address it?
CHALLENGE 10.28
Using the image that you created in the previous challenge to implement Figure 10.43, implement the
code in Figure 10.45 and experiment with the values of the border-image-slice and border-image-
repeat properties. For example, move the fill around for the former and use two different values for
the latter.
CHALLENGE 10.29
Given your knowledge from Chapter 6 of the use of images and accessibility, what accessibility
considerations, if any, are necessary when using an image for an element’s border (i.e., for
decoration), and why?
10.4.1.7 border-radius
The border-radius property is a shorthand property used to make the corners of a box round. It is non-
inherited and takes one or two sets of values, each comprising one to four space-separated values, which
can be in length values (e.g., px and em) or percentage values. When one set of values is specified, the
corners drawn are circle- based, with each value representing the radius for each corner. When two sets
of values are specified, the corners drawn are ellipse-based, with the first set representing the horizontal
radii and the second set representing the vertical radii. The two sets of values are separated by a forward
slash (/), as in 12px/5px. Table 10.11 describes how a set of values is interpreted.
Longhand border-radius properties are also used for specifying radius or radii for individual corners.
They are border-top-right-radius, border-bottom- right-radius, border-bottom-left-radius, and border-top-
left- radius, all of which are also non-inherited. Figures 10.47 and 10.48 show how the shorthand
property is used with one value and depict the result.
TABLE 10.11
How the Values of the border-radius Property Are Assigned
Number of Application of Values
Values
One Value is assigned to all four corners.
Two First value is assigned to top-left and bottom-right corners, and second value is assigned to top-right and bottom-left
corners.
Three First value is assigned to top-left corner, second to top-right and bottom-left corners, and third to bottom-right corner.
Four Values are assigned to top-left, top-right, bottom-right, and bottom-left corners, respectively.
FIGURE 10.47 Example usage of the border-radius property with a single value.
Each corner is drawn with a radius of 20px. The declaration could also have been written as border-
radius: 20px 20px 20px 20px . Notice that the content of the box is too close to the border. This is not
aesthetically pleasing. However, it can be rectified by using the padding property, which is discussed
shortly.
CHALLENGE 10.30
Implement the example in Figure 10.47 and experiment with the value of the radius to see how the
shape of the corners changes and the limit.
CHALLENGE 10.31
Using longhand border-radius properties, write the code to implement the same output as the
declaration: border-radius: border-radius: 25px 25px 25px.
Figures 10.49 and 10.50 show how horizontal and vertical values are used with the border-radius
property and depict the rendered result. The border-radius in the p.one{} rule says to use a horizontal
radius of 25 em and a vertical radius of 1.5 em to draw all four corners. The border-radius in the p.two{}
rule specifies a set of four horizontal radii, followed after the slash by a set of four vertical radii.
FIGURE 10.49 Example usage of the border-radius property with two radii.
Using horizontal and vertical radii allows you to create non-symmetric and interesting shapes and even
a circle, which is achieved, for example, by using the same width and height for the box and any radius
more than half their size (e.g., { width: 100px; height: 100px; border-radius: 50%; }). Unfortunately, it is
not always easy to produce the required shape with the border-radius property. To help out, there are free
online border-radius generators, such as cssmatic.com, that allow you to design boxes with different
combinations of radii and generate the corresponding code.
CHALLENGE 10.32
Using the <div> element, create an empty box with fixed width and height, and with the top-left and
bottom-right corners having the same radius and the top-right and bottom-left corners having same
radius that is different from the one used for top-left and bottom-right corners. Also, give the border
one color and the background a different one.
10.4.2 padding
The padding property is a shorthand property for specifying the amount of space between the content of an
element and the element’s border. It is the space that surrounds the content. It is non-inherited and has the
initial value of 0. It takes one to four space-separated values, which can be in length values (e.g., px and
em) or percentage values. If percentage is used, then padding is a percentage of the width of the parent
element. For example, if it is directly in a browser window, then it is a percentage of the window’s width,
and if it is in another box, then it is a percentage of the width of the box. How values are assigned is
explained in Table 10.12.
The longhand properties for specifying different padding values for each edge of a box are padding-
top, padding-right, padding-bottom, and padding- left, all of which are also non-inherited. Figures 10.51
and 10.52 show how the shorthand property is used and depict its effects.
TABLE 10.12
How the Values of the padding Property Are assigned
Number of Values Application of Values
One Value is assigned to all four edges.
Two First value is assigned to top and bottom, and second value is assigned to right and left.
Three First value is assigned to top, second to right and left, and third to bottom.
Four First value is assigned to top, second to right, third to bottom, and fourth to left.
CHALLENGE 10.33
Write a code that applies padding to the example in Figures 10.47 and 10.48. How do you think this
contributes to the quality of the presentation of the content?
FIGURE 10.53 Example usage of properties for specifying padding for logical edges.
CHALLENGE 10.34
Go to the “Specifying Content Directionality” section of Chapter 14, make note of other values for
the writing-mode property, and try them in the example to see the effects.
10.4.3 margin
The margin property is a shorthand property for specifying the amount of space around the outer edge of
an element’s box and serves to separate one box from another. Like the padding property, it is non-
inherited and has the initial value of 0. It also takes one to four space-separated values, which can be in
length values (e.g., px and em), percentage values, or auto keyword. If percentage is used, the value is
relative to the width of the containing element’s box. The auto keyword leaves it to the browser to
determine margin values as it sees fit. How values are assigned is explained in Table 10.13.
The longhand properties of the margin property are margin-top, margin- right, margin-bottom, and
margin-left. Figures 10.54 and 10.55 show how the shorthand property is used and depict the effects.
TABLE 10.13
How the Values of the padding Property Are Assigned
Number of Values Application of Values
One Value is assigned to all four edges.
Two First value is assigned to top and bottom, and second value is assigned to right and left.
Three First value is assigned to top, second to right and left, and third to bottom.
Four First value is assigned to top, second to right, third to bottom, and fourth to left.
In the example, the first rule applies to all <p> elements, while each of the remaining rules applies to
individual <p> elements of matching class. Note that setting margin to auto, as done in the example,
horizontally centers a box in the browser window or inside the element’s box that it is in. As mentioned
earlier, if width is not specified, a box occupies the full width of the page, making it impossible to center
it. Notice in the example that the text is not centered in the box. To do this, you need to use the text- align
property, discussed in Chapter 14.
NOTE: Vertical distance between boxes
The vertical distance between two adjacent boxes (blocks) is determined by the greater of the
values of the margin-bottom and margin-top properties. For example, if margin-bottom is 20px
and the margin-top is 10px, 20px is used.
CHALLENGE 10.35
Which is outside an element’s box, padding or margin? Also, what is the longhand of margin: 15px
5px?
CHALLENGE 10.36
What is the difference between margin and padding? Which would you use to change the space
between elements, and which would you use to change the space between an element’s border and its
content?
FIGURE 10.56 Example usage of properties for specifying margin for logical edges.
FIGURE 10.57 The result of Figure 10.56.
CHALLENGE 10.37
Again, go to the “Specifying Content Directionality” section of Chapter 14, make note of other values
for the writing-mode property, and try them in the example to see the effects.
FIGURE 10.60 The result of default (left), and the result of Figure 10.59 (right).
CHALLENGE 10.38
Implement the example in Figures 10.59 and 10.60, populate the boxes, and then manipulate the size
of the browser’s window to see the effect.
CHALLENGE 10.39
In the example, if the width of the document is 960px (a standard width for layouts), what will be the
rendered widths of the <div> elements with default box-sizing setting?
CHALLENGE 10.40
Using the example in Figure 10.61 as guide, create a <div> element, populate it, then create a
smaller size <div> element or <p> element inside it, and populate it too. Then, specify the resize
property for both elements and see the effects when the boxes are resized. Also, can you think of any
applications for such a design?
In the example, the p.one{} rule specifies the x-y offsets as 5px 5px, a blur-radius of 5px, spread radius
of 0px, and a shadow color of #4d4d4d. Rules p.one_up{}, p.one_blur {}, and p.one_center_no_blur {}
follow the same pattern. The p.one_center{} and p.multi{} rules have the inset keyword to specify an
inner shadow. The p.multi{} rule also shows how multiple shadows are specified, as well as uses em unit
instead of px. Notice that they are separated by a comma and that the inset keyword is only at the start of
the rule, not at the start of every shadow setting.
CHALLENGE 10.41
Thinking of the various features of a Web page, list some possible useful applications of the box-
shadow property in Web design.
CHALLENGE 10.42
Implement the example, using your own content, and then experiment with the width to see how this
affects the content.
CHALLENGE 10.43
A common application of the outline property is its use for creating the rollover effect, in which an
element changes appearance when the cursor is over it. In the example, replace the p.one selector
with p.one:hover to see how outline behaves when the cursor is over the first <p> element. Then, do
the same thing with the p.two selector. Explain why the second <p> element moves when the cursor
is over it and the first one does not. The :hover pseudo-class selector was first briefly introduced in
Chapter 8. More example applications are shown in Chapters 12-18.
10.7.1 outline-offset
The outline-offset property is non-inherited. It allows you to specify a transparent space between an
outline and the border of an element. The only value that it takes is a length value, such as px and em. A
negative value draws outline inside border and the element. Figures 10.67 and 10.68 show how it is used
and the result.
CHALLENGE 10.44
Given that outlines take no space and are placed over elements, what happens when an outline has a
negative value and is thick?
CHALLENGE 10.45
Implement the code presented in Figure 10.69 and experiment with the values of various properties
to see their effects, especially the padding and the box- shadow; then, create your own design,
putting more space between the buttons. (Hint: Consider character entity references discussed in
Chapter 3).
CHALLENGE 10.46
In the example code, remove the end tags from the <li> elements to remove the gaps between the
buttons.
CHALLENGE 10.47
Write a CSS code to render the HTML code below to produce the output that follows.
< h 3> Inline-block< / h 3 >
<div>This text is in a block element displayed as a block element, <p>while this text is in a
block element displayed as an inline element</p>, and this also is text in a block element
displayed as a block element.</div>
Inline-block
This text is in a block element displayed as a block element while this text is in a block element
displayed as an inline element, and this also is text in a block element displayed as a block element,
FIGURE 10.71 Using the none value with the display property to hide an element.
CHALLENGE 10.49
Write a CSS code to make the content of the second <p> element in the code below invisible:
<body>
<p>This paragraph is visible.</p>
<p>This paragraph should not be visible.</p>
</body>
CHALLENGE 10.50
What creative and accessible uses can you find for the visibility property, bearing in mind that it
hides content from all users, including screen reader users?
11.1 Introduction
Being able to orientate an element’s box or change its shape is useful for many creative and interesting
concepts in Web design, both static and dynamic. The provision of various transform properties in CSS
allows this to be done relatively easily and the use of element transformation is becoming increasingly
common, especially its animation, which is discussed in Chapter 18. This chapter presents these
properties, how to use them, and their effects.
11.3.1 transform-origin
The transform-origin property is a non-inherited property that allows you to specify the origin for the
transformation of an element and used with the transform property. The position of the origin has an effect
on the result of a transform operation. By default, the origin of an element is at its center. Table 11.1 lists
the values the property supports.
TABLE 11.1
Values for the Transform-Origin Property.
11.3.2 transform
The transform property allows you to specify how the coordinates of an element should be modified. It is
non-inherited and the values it supports are the none keyword and transform-functions, which allow
various types of transformations to be specified. Table 11.2 lists the functions supported. Multiple
functions can be specified in a list of space-separated values.
TABLE 11.2
Values for the transform Property
11.3.2.1 Applying Rotation and Skewing
Figure 11.1 shows how the rotate() and skew() functions are used and Figure 11.2 the result. The div{}
rule styles all the boxes in the same way (using properties already discussed in the chapter) and uses the
display:inline-block declaration to place them on the same line. The text-align:center declaration centers
the text in the boxes and, again, is discussed more fully in Chapter 14. The #box2{} rule rotates the
second <div> element clockwise around the z-axis by 45°. The #box3{} rule skews the third <div>
element along the x-axis by 30° by moving its points by amounts equivalent to the angle.
Figure 11.3 shows the effect of setting the transform-origin property to 0px 0px (i.e., top left corner of
an element). This is done by adding transform-origin: 0px 0px; to the #box2{} rule in Figure 11.1.
CHALLENGE 11.1
Implement the code in Figure 11.1 and experiment with the parameters of the functions, including
negative values, to know how they work and better use them.
CHALLENGE 11.2
In the example, where do you understand the transform-origin and the axis of rotation of the rotated
box to be?
CHALLENGE 11.3
Implement the example by adding transform-origin: 0px 0px; to #box2{} rule in Figure 11.1. In
reference to what is the 0px 0px, is it #box2 or the browser window? Also, what would be the effect
if the same declaration is added to the #box3{} rule? Lastly, experiment with different values.
CHALLENGE 11.4
Write a code to create something similar to Figure 11.5 but with rotation around the x-axis.
11.3.3 perspective
The perspective property is a non-inherited property and used to specify the distance between the user
and the z = 0 plane (i.e., vertical plane through the origin) so as to give perspective to a 3D-positioned
element and create the sense of depth. The smaller the distance, the greater the perspective produced.
Note that the property performs a different function from the transform property’s perspective() function
described in Table 11.2 and does not give perspective to individual elements, but to the children of an
element as a single unit. This means that it is applied to a parent element not the child elements. The
vanishing point, which is the point at which parallel lines meet, is by default at the center of the parent
element, but can be changed using the perspective-origin property. Figures 11.6 and 11.7 show an
example of usage and Figure 11.8 the result.
The example uses both the perspective property and the perspective() function for comparison. The
.parent{} rule styles the two parent <div> elements. The .parent.perspective{} rule gives perspective to
the element whose class attribute is equal to a list of space-separate values that includes “parent” and
“perspective.” Notice that there is no white space between .parent and .perspective selectors, since they
are part of a list of space-separate class values. The .parent .perspective .child{} rule rotates all elements
of “child” class around the x-axis by 30°. Notice that there is a space between .parent .perspective and
.child. This is because “child” is not part of a list of space-separated class values. The .child{} rule
styles each element of “child” class and changes them to inline-block elements to display them on the
same line. The .parent.transform .child{} rule specifies perspective and rotation values for each element
that is of “parent transform” class and also of “child” class.
CHALLENGE 11.5
Implement the example in Figures 11.6 and 11.7 and experiment with the values for the perspective
and perspective-origin properties and rotation. Also, see if you can make the code more efficient by
reducing the number of values for the classes.
FIGURE 11.11 The result of Figures 11.9 and 11.10. (Image from www.freeimages.co.uk.)
CHALLENGE 11.6
Implement Figures 11.9 and 11.10 using your own images and experiment with various properties,
including padding, margin, and max-width, to see the effect.
CHALLENGE 11.7
Implement Figures 11.9 and 11.10 again, but instead of specifying images that are stored locally on
your computer for the src attribute, link to images online. For example, you could link to free
placeholder images at www.lorempixel.com that randomly selects images from the categories
specified in the URL. More instructions on how to use them can be found at the site.
CHALLENGE 11.8
The border shown around the rendered output in Figure 11.11 is not the one created with CSS. Add
an actual border to the example and style it with inset shadows. Also, try adding the border property
to the rules to see the sizes and boundaries of the elements.
11.3.4 transform-style
The transform-style property allows you to specify whether the children of an element should be
displayed in 3D or in the same plane as the element (i.e., flat). It is non-inherited and supports two
values: preserve-3d (which displays children in the 3D space) and flat, the default (which displays
children in the same plane as the parent). Figure 11.12 shows their effects. A more detailed demonstration
of how the property is used is shown later in Figures 11.15 and 11.16, along with related properties.
CHALLENGE 11.9
For which of the following situations would you need to use the transform-style property: a <div>
element containing other <div> elements, or individual <div> elements?
11.3.5 backface-visibility
The backface-visibility property is non-inherited and used to specify whether or not the backface of an
element should be visible, making it look as if it is being reflected in a mirror. The values supported are
visible (which makes the backface of an element visible) and hidden (which makes the backface of an
element invisible). Figure 11.13 shows an illustration of the effects of these values and Figure 11.14 their
effect with a 3D shape.
CHALLENGE 11.10
Write a code to produce something similar to the middle example in Figure 11.13.
FIGURE 11.13 The effects of the backface-visibility property.
CHALLENGE 11.11
In the HTML code in Figure 11.15, what would happen if the <div> elements that represent the
cube’s faces are ordered numerically in ascending or descending order?
12.1 Introduction
The positioning of elements at the desired points on a page is crucial in achieving the intended design.
Since HTML elements are typically displayed by default to the left of the page and design layouts require
more than this, the need for positioning them in Web design is a foregone conclusion. This chapter
presents the CSS properties used for positioning elements.
CHALLENGE 12.1
Rewrite the example without explicitly specifying static positioning.
CHALLENGE 12.2
Use the following to see the effect of positioning a paragraph relatively to the right and bottom edges
of the box:
body {margin-left: 60px;}
p { width: 600px;}
p.moveLeft{
position: relative;
bottom: 10px;
right: 50px;}
CHALLENGE 12.3
Go to the “Specifying Content Directionality” section in Chapter 14, make note of other values for
the writing-mode property and try them in the example to see the effects.
In the example, the h{} rule absolutely positions the <h2> element 10px from the top and 50px from the
left edges of the <html> element, since there is no next parent element. The background color has been
added to make it easier to see the layering of the elements. Note that the reason the absolutely positioned
element is so far from the top, even though only a value of 10px is specified, is because browsers usually
add margin to the top of the heading element. To remove the margin for the <h2> element in the example,
zero-margin declaration can be added to its rule.
CHALLENGE 12.4
To see how an absolutely positioned element behaves, implement the example and then resize the
browser until the scroll panel appears and then scroll the page up and down.
Notice that the result is similar to Figure 12.7. The h{} rule fixed positions the <h2> element 10px
from the top and 50px from the left edges of the <html> element. Again, the background color has been
added to make it easier to see the layering of the elements.
CHALLENGE 12.5
Like in the previous challenge, resize the browser until the scroll panel appears and then scroll the
page up and down to see how a fixed positioned element behaves.
CHALLENGE 12.6
Implement the example in Figures 12.8 and 12.9, using the logical offset properties introduced
earlier in Figure 12.5 under Relative Positioning.
CHALLENGE 12.7
In the example, the scrollbar affects only the text content of the <div> element of “content.” What
does the scrollbars of the browser window affect when the window gets too small for the content?
CHALLENGE 12.8
Implement the example in Figure 12.10, using the logical offset properties introduced earlier in
Figure 12.5 under Relative Positioning.
CHALLENGE 12.9
Modify the code in Figure 12.10 to add menu links to the sidebar.
In the example, as the user scrolls down, the “Article One” heading moves up, and when it gets to the
top edge of the browser window it stops there and remains there as the user continues to scroll down until
the “Article Two” heading gets there to replace it. The .art1{} and .art2{} rules specify the styles for the
two <div> elements. The auto values specified for the right and left margin ensure that the elements are
horizontally centered in the browser window. In the h2{} rule, the position:sticky and top:0px
declarations say to apply sticky positioning at 0px from the top of the browser window.
CHALLENGE 12.10
Implement the example, ensuring you have enough text in each paragraph so that the scroll bar can be
activated. Then use it to see how sticky positioning works. Also, experiment with the offset property
to see how it affects the positioning of the headings.
CHALLENGE 12.11
Again, implement the example in Figure 12.12, using the logical offset properties introduced earlier
in Figure 12.5 under Relative Positioning.
CHALLENGE 12.12
To help the understanding of the layout in the example, add border to header{}, .logo{}, .logo h1{},
and nav ul li{} rules to see the relationship between the elements. Also, experiment with the values
of the display property to see how they affect the menu.
CHALLENGE 12.13
In the example, make only the menu sticky, so that it is the only feature that sticks to the top during
scrolling.
CHALLENGE 12.14
Again, implement the example in Figure 12.16, using the logical offset properties introduced earlier
in Figure 12.5 under Relative Positioning.
In the .menubar li a{} rule, color:black makes the color of all the text in the <a> elements and the <li>
elements black and text-decoration:none removes the default underline decoration. The .menubar
li:hover{} rule changes the background color of any <li> element to orange when the cursor hovers over
it. The .menubar li ul {} rule styles the drop-down menu (i.e., <ul> of class=“dropdown_menu”). In it,
padding removes the padding for all edges so that the left edge is aligned with that of the menu; box-
shadow adds shadow to it; text-align:left aligns its content to the left; position:absolute absolutely
positions it; top:39px positions it so that its top edge is flush with the bottom edge of the menu; and left:0
positions it so that the left edge is aligned with that of the menu. This is necessary because <li> elements
are right-indented by default. In this case, they need to be moved left to 0, which is the position of the left
edge of the containing <ul> element.
In the .menubar li ul li{} rule, background: orange makes the <li> elements in the drop-down orange;
color:white makes the text white; and display:block makes the <li> elements behave like a block element
again. Recall that all <li> elements were made to behave like inline-block elements before.
In the .menubar li ul li a{} rule, color:white makes the color of the text in the <a> elements in the drop-
down menu white; and white-space: nowrap ensures that the text does not wrap to the next line. This
means that the longest text length determines the width of the drop-down menu. Alternatively, you could
specify a fixed width. The .menubar li:hover ul{} rule displays the drop-down menu when the cursor
hovers over the menu (i.e., <li> element in the <ul> element of class=“menubar”). The .menubar li ul
li:hover{} rule changes the background color of any menu item in the drop-down menu to grey when the
cursor hovers over it. This is any <li> element in the <ul> element of class=“dropdown_menu”.
CHALLENGE 12.15
Implement the example in Figures 12.17 through 12.19, using the logical offset properties introduced
earlier in Figure 12.5 under Relative Positioning.
FIGURE 12.20 HTML for drop-down menu using the <button> element.
CHALLENGE 12.17
In the example in Figure 12.22, what will happen if the <div> element is used instead of the <span>
element, and why?
CHALLENGE 12.18
In the CSS code in Figure 12.22, some properties are repeated for .peg1{}, .peg2{}, and .peg3{}
rules. Rewrite the code without the repetitions to make it more efficient. Also, state what you think
the pros and cons are of writing codes in this way.
In the blockquote{} rule in the example, width specifies the width of the <blockquote> element to
ensure that it does not occupy the entire width of the containing element (i.e., <body> element), border
gives the element black top and bottom line-style borders, margin specifies the amount of surrounding
space, padding specifies the amount of surrounding space for its content, background-color specifies its
background color, font-style italicizes the text content, and float says to float it right. The font-style
property is discussed fully in Chapter 13 and only used here for the purpose of demonstration. The
figure{} rule specifies margin for the <figure> element and font-style for its text content (i.e., the caption)
and also says to float the element left. Using the <figure> element rather than just the <img> element
makes it easier to include a caption with the image.
CHALLENGE 12.19
Can you think of any advantages to having a separate rule for the <figcaption> element to style its
content, rather than using the rule for the containing element (the <figure> element)?
CHALLENGE 12.20
Write a code to float three differently colored <div> elements so that they are aligned as shown
below:
TABLE 12.1
The Values Taken by the clear Property
Value Function
Left Moves element down to clear the elements on the left that are blocking it.
Right Moves element down to clear the elements on the right that are blocking it.
both Moves element down to clear the elements on both left and right blocking it.
none Element is not moved.
FIGURE 12.28 Example usage of the clear property.
CHALLENGE 12.21
Write a code to position <div> elements as shown below, using the float property:
12.3.9.1 A Common Problem with Non-Floated Parent Elements
It is sometimes desired to add a border around floated elements. In order to achieve this, it is necessary to
place the floated elements in a containing element that is not floated. However, when a non-floated
containing element contains only floated elements, browsers may display it as if it has a height of 0px.
This means that if the border property is specified for it, the border is collapsed and displayed as a line
above the floated elements, instead of around them. Figures 12.30 and 12.31 demonstrate this problem
using a code similar to that in Figure 12.28. Notice how the border of the <div> element is collapsed into
a top edge.
FIGURE 12.32 The rendered result of Figure 12.30 after adding overflow.
The problem demonstrated in the example can be solved in a number of ways, each of which has pros
and cons and therefore suitable for different design situations. The following are some of the commonly
used:
Giving the containing element specific height.
Floating the containing element.
Specifying the overflow property on the containing element and giving it the value of auto or
hidden. The property was introduced in and is actually designed to handle the content overflow
but works for this problem. To resolve the problem in Figure 12.31, overflow:auto; is simply
added to the div{} rule in Figure12.32. Figure 12.33 shows the result.
CHALLENGE 12.22
Write a code to display images in the same way as in Figure 12.32 instead of the text.
CHALLENGE 12.23
In what sort of situation do you think adding a border around floating elements as in Figure 12.32
would be desirable?
CHALLENGE 12.24
Create a three-column layout with each column having its heading.
In the example, the div{} rule specifies to create three 100px columns. The .article1{} rule says to
make the <h2> element of class=“article1” span only the first column (i.e., the default) and the .article2{}
rule says to make the <h2> element of class=“article2” span all the three columns. Note that even with the
use of vendor prefixes, as of time of writing, Firefox does not support the column-span property and span
is always one column.
CHALLENGE 12.25
Write a code that displays something similar to the following, using your own content for the text:
CHALLENGE 12.26
Modify the code in Figure 12.37 to make the heading span all columns.
FIGURE 12.38 The rendered result of Figure 12.37.
12.4.3 column-fill
As of time of writing, the column-fill property is only supported by Firefox and the -moz- prefix must be
used for it to recognize it. Figure 12.39 shows how it is used and Figure 12.40 the result. The div{} rule
specifies the number of columns and the rule. The .article1{} and .article2{} rules specify different -
values for the column-fill property. Notice that the div{} rule only takes effect when the value for column-
fill is balance.
CHALLENGE 12.27
Write a code that displays something similar to the one below. Please note that the column dividers
are double lines.
13.1 Introduction
In Chapter 3, how HTML elements are used to add and structure text was discussed. CSS allows you to
control the appearance of such text in various ways. Some of these include specifying typefaces, fonts,
size, and style. These text characteristics play many important roles in Web design, including influencing
how users perceive a page. In this chapter, the CSS properties used to specify these text characteristics
and the guidelines on how best to use the characteristics are discussed.
13.4.1 font-family
The font-family property allows a typeface or a list of typefaces to be specified for the text inside
selected element or elements. It is inherited and the two types of values it takes are described in Table
13.1.
A font family name or a generic font family name can be specified alone, or the two can be specified
together. When the two are used together, the generic family name is placed last. It is good practice to
specify a generic family name, as this ensures that the essence of a design is largely maintained even when
the specified font is not available. How it works is that when the browser displays a document, it uses the
first font from the list that it can find. Figures 13.2 and 13.3 show an example of how the property is used
and the result.
In the example, the body{} rule tells the browser to use Times, but if this is not available to use “Times
New Roman,” and if this is not found to use Georgia, and if this is not available use any serif font. The
h3{} and p.author{} rules are interpreted similarly. A prioritized list of fonts specified in the font-family
property is known as a font stack and various suggestions can be found on the Web.
TABLE 13.1
the values supported by the font-family property
Value Function
<family- This is the name of a font family, such as “Times” and “Helvetica.” font-family names containing whitespace are enclosed in quotes.
name> If a list is specified (which is good practice because there is usually no guarantee that the only font specified will be available on the
user’s system), the names on the list are comma-separated and prioritized according to suitability or preference.
<generic- Generic font family names are keywords and those supported are serif, sans serif, monospace, cursive, and fantasy. They must not
name> be in quotes. Generic font families are used as fallback to enable the browser to use the closest alternative when the specified font is
not found. When a list of names is specified, the names must be comma-separated.
CHALLENGE 13.1
Why is the font-family declaration in the rule below invalid?
body { font-family: Gill Sans Extrabold, Helvetica, sans-serif; }
CHALLENGE 13.2
When you change the order of the rules in Figure 13.2, the fonts applied to the elements do not
change. Can you explain why? Hint: Refer to specificity principle in Chapter 8.
13.4.2 @font-face
The @font-face at-rule allows online fonts and their URLs to be specified, so that copies can be
downloaded for use within a page. Fonts that are downloaded from the Web for use in a page are known
as Web fonts. They are very important in Web design, as they remove the restriction that specified fonts
must be installed on the user’s system. An additional advantage of the approach is that it allows the use of
custom fonts. Table 13.2 lists the descriptors that the at-rule takes and their functions, and Figures 13.4
and 13.5 show the basic use of the at-rule and the result.
In the @font-face{} rule in the example, the font-family specifies a made-up name “My Serif Bold” to
describe the font to be specified. This name could be anything, but must be in quotes if it contains white
space. The src property uses the url() function to specify the name and location of the font. In this case, it
says the font file is in the fonts folder/directory inside the folder in which the stylesheet referencing it is
located. The .one{} rule uses the font-family property as normal to specify to use the font declared in the
@font-face{} rule for the <p> element of class=“one”, quoting the made-up name and a generic font to
use if the specified one is not available.
In the example, all the glyphs in the specified font family are downloaded, even if only a small part of
them will be used. To minimize the amount of font data downloaded, just the set of glyphs required can be
specified using other descriptors listed in Table 13.2. For example, to limit the number of glyphs
downloaded to include only those that represent the normal font-style, you would include the font-style
descriptor and set its value to normal. Similarly, the unicode-range descriptor can be used to limit the set
of glyphs downloaded. Figure 13.6 shows an example of how this is done. It says to download from the
specified font family only the glyphs that represent normal characters in Latin and Japanese. The font-style
descriptor, and others in the table (i.e., font-stretch, font-weight, and font-variant), are fully discussed
later in this chapter as CSS properties.
TABLE 13.2
Descriptors Used In The @FONT-FACE At-Rule
CHALLENGE 13.3
Implement the example in Figure 13.4 and then misspell the family name in the font-family
declaration to see if the generic alternative used by the browser resembles the specified font.
The ?#iefix used with the eot value is to address font-loading problems with Internet Explorer 8 and
below, although just a question mark is usually enough. The # in the svg value points to the ID of the
<font> element that defines the svg font in the SVG file, so that only the font definition is loaded. Not
including the hash will cause the entire SVG file to be loaded, including headers that may prevent the
defined font from being recognized. The name after the # is the name given to the svg font when it was
created. If not known, it can be found by opening the SVG font file in a text editor and looking at the
beginning inside the opening tag of the <font> element. If all necessary formats for a font are not available
for the font you want to use, the font can be converted to different formats, using, for example, online
services, such as fontsquirrel.com, that provide format conversion. These websites convert fonts to just
the specified format or provide a folder containing all the common font formats. Either way, they also
typically generate the necessary CSS code for the @font-face rule. In all cases, once the @font-rule is set,
the relevant font is specified in the body{} rule, using the font-family property as normal.
CHALLENGE 13.4
Download a font into a folder called “fonts,” and then write a @font-face{} rule to use it.
In the examples in Figures 13.4, 13.6, and 13.7, the online font file, VeraSeBd.ttf, is downloaded from
the same Web server that serves the HTML document and the corresponding stylesheet. However, an
online font does not have to be located on the same server that serves the HTML document and the
corresponding stylesheet. It can be downloaded from another server, in which case, the absolute URL for
the location must be specified. Typically, you will get an online font from a Web font or font-hosting
service, such as Google Fonts, Typekit, FontSquirrel, Fonts.com, Font Deck, and Cloud Typography.
Using Web fonts from these services can typically be achieved through using the CSS @import rule,
which is used to import rules from other stylesheets. Font-hosting services would typically generate the
necessary @import rule for adding a font, which can then be copied and pasted. At Google Fonts, for
example, all that was required to obtain the @import rule used in Figure 13.8 to get the result in Figure
13.9 was to choose the required font and character set and the rule was automatically generated.
GoogleFonts also generates a link that can be used in the <link> element to link to a font file on its
server, much like when you link to an external stylesheet. For example, the following line links to the
same font file used in Figure 13.8.
<link href=“//fonts.googleapis.com/css?family=Indie+Flower” rel=“stylesheet” type=“text/css”>
FIGURE 13.8 Using the @import rule to specify font.
CHALLENGE 13.5
Write a code that uses the <link> element to link to a font at www.google.com/fonts and then write a
CSS to use it.
Other ways of grouping typefaces often prove to be easier to use and more useful than classifications,
including grouping them under:
Those that have serifs, known as serif typefaces.
Those that do not have serifs, known as sans serif typefaces.
Those that simulate handwriting, known as script or cursive typefaces.
Those that simulate fifteenth century Northern European manuscript decorative handwriting,
known as decorative or fantasy typefaces.
Whether they are suitable for body-text or display.
Whether they are monospaced or proportionally spaced.
CHALLENGE 13.6
Compare and contrast serif and sans serif typefaces and then say which you would use for the
following, giving your reasons:
Headings
Subheadings
Body of text
Emphasized words
13.4.3.2.2 Legibility
Legibility is whether people are able to see, distinguish, and recognize the characters and words of a text.
This should not be confused with readability, which more describes how easy the words and sentence
structure of a text are to understand. A typeface should be used that has letters and characters that have
good level of legibility. Typefaces that enable this include:
Typefaces with conventional letterforms, that is, without novel shapes or characteristics, as these
make it difficult for readers to quickly recognize letters.
Typefaces with ample spacing, as very tight spacing can, again, make it difficult to recognize
letters and words. Note, of course, that it is possible to increase letter-spacing for any typeface in
most text production programs. Letter-spacing is discussed later in the chapter.
Typefaces with x-height that is not too small, as a small x-height can make some letters less
legible; for example, the smaller the x-height, the less distinguishable some lowercase letters,
such as “c” and “e,” become.
Typefaces designed to enhance legibility, such as body-text typefaces discussed earlier. If
numbers are involved, whether or not a typeface has numbers that are as legible as the letters
should be checked.
Typefaces which look similar across different operating systems and devices. For example, text
that renders smoothly on a Mac may render less smoothly on a PC and be less legible.
CHALLENGE 13.7
State whether or not you think the sensory information communicated by the fonts in the example
below matches or complements the words for which they are used? Also, give your reasons.
CHALLENGE 13.8
Why is a typeface that has a lot of fonts required for extended hierarchy of importance? Also, is
using an extended type family for a personal website appropriate and why?
FIGURE 13.17 Mixing lower- and uppercase and typeface in text design.
CHALLENGE 13.9
In what types of situations might you combine fonts in the way shown in the box? Also, write a code
to display one of the combinations or one of your own, also in mixed colors.
13.5.1 font-size
The font-size property is used to specify the size of font for selected HTML elements, pseudo-element, or
pseudo-classes, and whatever value is set may change the size of other items, if they are in relative
lengths like em, percentage, and ex. The property is inherited and Table 13.3 lists the types of values the
property takes.
TABLE 13.3
Types of Values Supported by the font-size Property
Type Description
Absolute Comprises the absolute-size keywords, xx-small, x-small, small, medium, large, x-large, and xx-large, which are relative to the
size default size set by the user, which is regarded as medium.
Relative Comprises the keywords, larger and smaller, which are relative to the parent element’s font size. The amount of increment or
size decrement is roughly the same as that between neighboring absolute-size keywords.
Percentage Refers to a percentage of the font size of the parent element. The current size is 100%. For example, the default size of text in a
browser is 16px, so, 16px is 100%., and a size of 32px is 200%.
Length Refers to distance measurements, which can be absolute units (e.g., px, pt, in, cm, mm, pc) or relative units (e.g., em, ex, ch, rem,
vh, vw, vmin, vmax)
Each of the value-types or their combination is suitable for different Web design situations. For
example, keywords make it easy to scale size up or down relative to the font size of body element, length-
based types like px are good for accuracy, and relative types like % and em in combination with px, for
example, are good for scalable and dynamic designs. Table 13.4 further defines standard length units.
TABLE 13.4
The Length Units Supported by the font-size Property
Length Description
Units
px The actual size of a pixel (px) is relative to device and may represent one or more dots on the screen, depending on screen resolution.
So, the same size will look different on different-resolution screens. The following are its relation to other absolute units: 1in (or 2.54
cm or 25.4 mm) is equivalent to 96px. 1px = 3/4pt; 1pt = 4/3px.
em This represents the size of the text in the parent element and allows you to change the size of text for any child element relative to
this. For example, if the size of text in the parent element is 12px, then 1em is 12px, and 1.5em is 18px. Em is also usually the width of
the letter “m” of the relevant font.
rem This unit (root em) represents the font size of the document’s root element (i.e., <html> element). It is used mainly for scalable
layouts.
ex This represents the x-height of a font and is rarely used.
vh, vw, These are viewport-percentage units and specify lengths relative to the size of the viewport, thus, vh specifies 1/100th of height, vw
vmin, 1/100th of the width, vmin 1/100th of the minimum value between the height and width, and vmax 1/100th of the maximum value
vmax between height and width.
Figures 13.18 and 13.19 show an example of how to use the font-size property with various types of
values, and Figure 13.20 shows the result.
In the example, the body{} rule specifies a font and makes all text 12px. The .xxsmall{} and .small{}
rules display the text in the elements of class=“xxsmall” and class=“small” in reduced absolute sizes that
are based on the browser’s default font size (i.e., 16px). The .larger{} rule displays text in enlarged
relative size based on the font size specified for the parent element (<body>, in this case). The .percent{}
rule displays text at 200% (twice) larger than the font size of the parent element and, likewise, the .em{}
rule displays text at 1.5 times larger than the font size of the parent element. Note that if no font size is
specified for the body element, the size of the element usually defaults to default browser size.
CHALLENGE 13.10
In the example in Figure 13.19, if no font size is specified for the <body> element, what font size
applies?
13.5.2 font-size-adjust
The font-size-adjust property is sometimes used with the font-size property to ensure the legibility of
lowercase letters when a font is substituted. This is useful because sometimes when the specified first-
choice font is unavailable and an alternative is used by the browser, lowercase letters in the alternative
font might not be legible. The property is inherited and allows you to specify that the font size should be
chosen based on the height of the lowercase letters (i.e., x-height) instead of the height of the uppercase
letters. The values it supports are none and number values. The number is usually set to the aspect ratio
of the first-choice font. The aspect ratio of a font is the ratio of its x-height to its height (i.e., x-height
divided by the font size). See Figure 13.1 earlier for more on these properties. When the aspect ratio is
specified, the browser basically adjusts the size of the available alternative font so that its aspect ratio
matches the one specified. For example, in the example in Figure 13.21, the browser adjusts the aspect
ratio of the alternative font to 0.58. More specifically, it multiplies the specified number by the font size
of the first-choice font and adjusts the x-height of the lowercase letters of the alternative font to match the
result. In the example, this x-height would be roughly 6 (i.e., 0.5 × 12px). You can find the aspect ratios
for common fonts on the Web.
Structuring text in this way (along with the application of other types of styling) guides the reader’s
eyes easily through the content of a design. There is no one correct set of sizes for achieving a good visual
hierarchy, since what is suitable and acceptable depends on various factors, including typeface and screen
size. However, the size used for the body of text should be the smallest in all cases, or at least not larger
than those of headings or subheadings. One general guideline is that whatever the sizes used, they should
be from the sizes in the typographic scale, shown in Figure 13.23.
The scale was developed in the sixteenth century by European typographers and it was believed that
using only sizes from it can more easily produce an aesthetically pleasing design than selecting outside it.
The scale has carried through till today and its variants are what are offered today in virtually any
application that allows the font size to be specified. So, although other sizes can be used in Web design, it
is good practice to consider the sizes from the scale or its variants in the first place. While the scale is in
points (pt), the size ratios can be achieved using the units more commonly used in Web design, such as
pixels (px), percentages (%), or EMs (em).
13.6.1 font-weight
The font-weight property is an inherited property that is used to specify the weight or boldness for the
textual content of an element. While some fonts are only available in normal and bold, others are in
various weight levels. This means that a variety of values are supported by the property, including
normal, bold, lighter, and bolder keywords, and numeric weight values, which include 100 (thin), 200
(extra light), 300 (light), 400 (normal), 500 (medium), 600 (semi bold), 700 (bold), 800 (extra bold), and
900 (heavy). In order for these values to have an effect, the relevant typeface must have them. If the
specified value is not available, the browser uses various schemes to determine an alternative. Note that
weights hold no semantic meaning to the browser. If you want to assign importance to a text, you should
use the <strong> element introduced in Chapter 3. Figure 13.24 shows how the font-weight property is
used and Figure 13.25 the result.
CHALLENGE 13.11
Use the @import rule to import a font from Google Fonts, as shown earlier, and then use the font-
weight property to display all its weights to get a feel of the differences between the values.
CHALLENGE 13.13
For which of the following would you use italic and why?
An emphasized word.
Body of text.
Important words.
A word to register in user’s mind.
13.8.1 font-feature-settings
The font-feature-settings property is inherited and allows you to control over the advanced typographical
features of OpenType fonts, which are scalable fonts. The values it supports are normal keyword (which
specifies to use default settings) and feature-tag-value (which specifies the list of comma-separated
OpenType feature tag-values to use). A tag value indicates which feature to turn on or off. The on and off
keywords can be used. For example, p { font-feature-settings: “smcp”; } specifies to turn on the small-
caps feature, and p { font-feature-settings: “smcp” off; } says to turn it off.
13.8.2 font-synthesis
The font-synthesis property is used to specify which missing typefaces, italic or bold, can be synthesized
by the browser if needed. It is inherited and the keyword values it takes are none (says nothing should be
synthesized), weight (says to synthesize bold), and style (says to synthesize italic). The following rule, p {
font-synthesis: bold; }, for example, says to synthesize bold typeface for the content of the <p> element.
13.8.3 font-variant
The font-variant property is inherited and shorthand for all font-variant subproperties, such as font-
variant-caps, font-variant-numeric, font-variant-alternatives, font-variant-ligatures, font-variant-position,
and font-variant-east-asian. Table 13.5 lists the functions of these properties. The rule, p {font-variant:
small-caps; }, specifies to display the content of <p> element in small capital letters. The longhand would
be p {font-variant-caps: small-caps; }.
TABLE 13.5
Longhand font-variant Properties
13.8.4 font-stretch
The font-stretch property is used to select the most appropriate face (design), if more than one is provided
for a font. Unlike the name might suggest, the property does not stretch a font, but simply selects a face. It
is inherited and the values it takes are normal (which specifies a normal font face), semi-condensed, -
condensed, extra-condensed, and ultra-condensed (all of which specify a face more condensed than
normal), and semi-expanded, expanded, extra-expanded, ultra-expanded (all of which specify a face more
expanded than normal). Naturally, these values only take effect if a font provides the faces. Example
usage: h1 {font-stretch: extra-expanded; }.
CHALLENGE 13.14
One of the more commonly used of the more advanced properties just presented is the font property,
as it can be efficient. Use the rule, p { font: bold small-caps bolder 18px/3em “Open Sans” sans-
serif; } for a paragraph and experiment with the values to see how the property works.
14.1 Introduction
In addition to typefaces and fonts, various other factors play a role in shaping the look of text in design.
These include alignment, indentation, spacing, capitalization, directionality, and decoration. This chapter
presents the CSS properties used to control these factors.
14.3.1 text-align
The text-align property is inherited and allows you to specify the alignment of inline content in its parent
block element’s box. The commonly supported values are listed in Table 14.1.
TABLE 14.1
Commonly Used Values for text-align
Value Function
left Aligns text to the left edge of an element’s box.
right Aligns text to the right edge of an element’s box.
center Aligns text to the center of an element’s box.
justify Aligns text with both the left and right edges of an element’s box.
justify-all Same as justify, except that the last line is also justified.
Figures 14.1 and 14.2 show how the property is used and the result. The heading is aligned to the
center and the paragraph justified.
FIGURE 14.1 Example usage of the text-align property.
CHALLENGE 14.1
Write a code that displays blocks of text with right, left, and center values. The border of each of the
elements containing the texts must be shown and the boxes must be positioned at the center of the
browser window. Hint: See , 11, and 12 about how to show borders and position boxes,
respectively.
CHALLENGE 14.2
In the previous challenge, see if you agree that some types of text alignment make the text more
difficult to read than others and give your reasons for not agreeing.
14.3.2 vertical-align
The vertical-align property is used to specify the vertical alignment of inline box, or table-cell content,
rather than the text inside the block-level elements. It is inherited and common to use it with the <img>
element to align images within the text. The values it takes are shown in Table 14.2 and Figures 14.3 and
14.4 show examples of how some of them are used and how they render.
TABLE 14.2
The Values for vertical-align Property
FIGURE 14.3 The values for vertical-align property.
CHALLENGE 14.3
Implement the code in the example, using an image of your choice, and modify the code so that a
border shows around each image and the <p> element and each paragraph has a background color.
Do you think this is an improvement aesthetically? Also, what would happen if the container
elements are <div> elements?
CHALLENGE 14.4
In the p.blocktext{} rule, in the example in Figure 14.5, use the shorthand margin property to achieve
the same goal achieved by the two longhand properties.
The example essentially uses the position property to position the <div> element at a fixed point 50 -
(halfway) down the window’s height. The transform property takes the translateY(-50%) as value, which
moves the <div> element up the y-axis (vertical axis) by half its own height to properly align the middle
of the element’s box with the vertical middle of the window. This is because the position property
positions an element using the top-left corner and not the center.
CHALLENGE 14.5
In the example in Figure 14.7, why would you not use “relative” for the value of the position
property?
CHALLENGE 14.6
Implement the example in Figure 14.9 and experiment with the value of the transform property,
including the sign. Also say why it is more effective to use % instead of px or em.
CHALLENGE 14.7
Implement the example, making the margin-left larger than the text-indent value to see the effect and
why the paragraph has to be moved right by the same amount of indent.
The rules in the example and their effects are self-explanatory. In the rendered outputs of the
.kerningnormal{} and .kerningnone{} rules, notice the differences in spacing between some letters (i.e.,
“A,” “W,” “A,” “V,” “L,” and “Y”). Notice also that the text looks better when the kerning information is
applied.
CHALLENGE 14.8
What is the possible implication of using the em unit to specify text spacing?
14.5.2 text-rendering
The text-rendering property is actually not a CSS-defined property as of time of writing but supported by
most browsers. It is inherited and used to optimize text spacing and balance quality against rendering
speed. The values supported include auto (which lets browser decide), optimizeSpeed (which prioritizes
speed over legibility and geometric precision), optimizedLegibility (which optimizes legibility over
speed and precision), and geometricPrecision (which optimizes geometric precision). A rule, for
example, could be p { text-rendering: optimizeReadability; }.
CHALLENGE 14.9
Write a code to display the words “LAWFULLY” and “Lawfully” in Times New Roman and Arial,
without using the kerning information, to see the differences in the spacing between the letters.
14.6.1 line-height
The line-height property is inherited and used to specify the spacing between one line of text and the next.
The values it supports are listed in Table 14.4 and Figures 14.15 and 14.16 show how the line-height
property is used and the result.
TABLE 14.4
Values Taken by the line-height Property
Value Function
normal Specifies to use the browser’s default. Value depends on font-family, but is commonly between 1.2 and 1.4.
<number> Any unit-less integer or fraction. However, it does not specify the actual spacing directly. The value used is the number
specified multiplied by the element’s font-size. It is the most preferred, because it does not produce unexpected results.
<length> Distance measurement (e.g., px and em). May produce unexpected results.
<percentage> Percentage relative to the element’s font size. May produce unexpected results.
Notice in the example the unexpected result produced by the em unit with a larger font size, even though
the text in smaller font size looks all right. This problem can also happen with other measurement units
like px.
CHALLENGE 14.10
Implement the example in Figure 14.15, using a text of your choice, but express the line-height in the
div.unit{} rule in percentage.
CHALLENGE 14.11
What is the actual value used for the line spacing in the example, given the 1.2 value specified in the
div.unit-less{} rule?
CHALLENGE 14.12
Mark up some words in the previous example with the <sup> and <sub> elements and apply line-
height to the elements to see the effects.
CHALLENGE 14.13
Write a code to produce the following:
PLEASE DO NOT IGNORE WARNINGS, AS THIS CAN LEAD TO FATAL ACCIDENTS!
CHALLENGE 14.14
For which of the following would you use or not use all-uppercase, and why?
Subheading
Advice
Welcome greeting
Body of text
Small text
Quotation
14.8.1 direction
The direction property is generally equivalent to the HTML dir attribute introduced in Chapter 3. It is
used to specify the inline base direction of the content of an element, but can also be used with the
unicode-bidi property to override the ordering of the characters of text, as can be done using the <bdo>
element discussed in Chapter 3. It is inherited and the values it takes are ltr (which displays content left
to right and is default) and rtl (which displays content right to left). When used on a <table> element, it
contributes to how the contents of table columns are ordered. It can also be used on specific <tr>, <td>,
and <th> elements. Figure 14.19 shows example of how it is used and Figure 14.20 the effect.
CHALLENGE 14.15
Why should you use HTML to specify text directionality instead of CSS?
14.8.2 writing-mode
The writing-mode property allows you to specify whether the inline content should be laid out
horizontally or vertically, and the direction of block flow (i.e., direction in which new lines are stacked).
It is inherited and the values supported are listed in Table 14.6. Figures 14.21 and 14.22 show how the
property is used, using English and Japanese, and Figure 14.23 the effects.
In the example, horizontal-tb was used for the content of each cell in the first row; vertical-lr for those
in the second, and vertical-lr for those is the third. The horizontal and vertical scripts say “Introduction to
Writing Modes,” while the mixed script says “Introduction to Writing Modes 2016.”
TABLE 14.6
Values Taken by the writing-mode Property
Value Function
horizontal- Makes the content flow horizontally from left to right and top to bottom.
tb
vertical-rl Makes the content flow vertically from top to bottom and horizontally from right to left.
vertical-lr Makes the content flow vertically from top to bottom and horizontally from left to right.
sideways- Makes the content flow vertically from top to bottom and left to right, with glyphs set on their side to the right. May not be used in
lr the future.
sideways- Makes the content flow vertically from top to bottom and right to left, with glyphs set on their side to the left. May not be used in
rl the future.
FIGURE 14.21 HTML for example usage of writing-mode.
CHALLENGE 14.16
Which writing-mode value would you use for text that is written from right to left and top to bottom?
14.8.3 text-orientation
The text-orientation property allows you to specify the orientation of text within a line. It is useful for
controlling how vertical scripts are displayed and also for presenting table headers. As of time of writing,
it only has an effect on vertical writing mode. It is inherited and the values it supports are listed in Table
14.7. Figure 14.24 shows their effects using English and Chinese text.
TABLE 14.7
Values Taken by the text-orientation Property
Value Function
mixed Turns horizontal-script characters 90 clockwise and leaves the vertical-script glyphs upright, unchanged.
upright Leaves both horizontal-script characters and vertical-script glyphs upright, unchanged.
sideways Turns both horizontal-script characters and vertical-script glyphs 90 clockwise, as if the whole line has been displayed horizontally
and then rotated 90 clockwise. It is the same as sideways-right, which is used for backward compatibility.
FIGURE 14.24 The effect of the text-orientation.
To achieve the example, each of the three rules used to specify the text-orientation property also
specifies the writing-mode property with the value of vertical-rl.
CHALLENGE 14.17
Using the table-based method used in the previous example, see if you can create Figure 14.24. You
can get the Chinese script from Google Translate. Hint: The syntax for the text-orientation property
is text-orientation: value, for example text-orientation: upright.
14.8.4 text-combine-upright
The text-combine-upright property is used to combine and place multiple characters in the space of a
single character in vertical writing mode. The combined text must not be displayed wider than 1em and is
displayed as a single upright glyph. If there are too many characters in a sequence to fit into 1em (e.g.,
2016), the characters are not combined; rather, each character is displayed vertically and upright. The
property is often used to display horizontal text (e.g., Latin-based dates and initials) in East Asian
documents. The property is inherited and only has effect in vertical writing mode. Table 14.8 list the
values it supports and Figures 14.25 and 14.26 show its usage and the illustration of the effect.
TABLE 14.8
Values Taken by the text-combine-upright Property
Value Function
none Applies no special processing. It is the default.
all Tries to fit all consecutive characters in an element horizontally into the space of a single character within a vertical line box.
digits<integer> Tries to fit into the space of a single character in a vertical line box a sequence of consecutive ASCII digits (1–9) that contains
as many digits as, or fewer digits than, the specified integer. If the integer is missing, the value of 2 is used. Only an integer
range of 2–4 is supported.
FIGURE 14.25 Example usage of text-combine-upright property.
In the example, the .date{} rule says to fit two characters into the space for one. Note that Figure 14.26
does not show the actual output of the code, only a rough illustration of what should be produced, as the
property is not yet supported by major browsers as of time of writing.
CHALLENGE 14.18
The date in the example can also be marked up with the <date> element discussed in Chapter 5. How
would you do this and which of the two approaches is more appropriate for the example, and why?
14.9.1 text-decoration
The text-decoration property is a non-inherited shorthand property used to specify the text formatting or
the decoration to apply to a text. It allows you to specify lines, how to use them, the style and the color, all
at once, in any order. Its effects always extend to all child elements of the element to which it is applied.
For example, if it is applied to a <p> element that contains a <span> element, the <span> element is also
affected and the effects cannot be disabled. The longhand properties are text-decoration-line, text--
decoration-style, and text-decoration-color. Table 14.9 lists the values supported by the text-decoration-
line and Table 14.10 lists those supported by the text-decoration-style. Color value is specified for text--
decoration-color in the same ways as described earlier in Chapter 9.
Figure 14.27 shows various ways the property is used and Figure 14.28 shows the result. The
p.under{} rule specifies only type of line. The p.through{} rule specifies the line type, style, and color.
Notice that the p.over{} rule specifies the same things, but in a different order. Notice also in
p.overunder{} that more than one type of line can be specified at once, along with style and color. As of
time of writing, most browsers support only underline. Firefox supports all values except blink.
TABLE 14.9
The Values for text-decoration-line Property
Value Function
underline Draws a line under text.
overline Draws a line over text.
line-through Draws a line through text.
blink Makes text flash. However, it can be annoying, because it continually attracts the user’s attention.
none Removes the currently applied decoration from a text, including the underline from a hyperlink.
TABLE 14.10
The Values for text-decoration-style Property
Value Function
solid Draws a single line.
double Draws a double line.
dotted Draws a dotted line.
dashed Draws a dashed line.
wavy Draws a wavy line.
CHALLENGE 14.19
Write the following rule using the longhand text-decoration properties.
p.overunder{ text-decoration: overline underline double red; }
14.9.2 text-decoration-skip
The text-decoration-skip property is inherited and used to specify which parts of an element’s content the
text decoration line affecting it must skip. It affects both the text decoration lines drawn by the element to
which it is applied and those by the parents. So, for example, if text-decoration-line is applied to a <p>
element that contains a <span> element to which text-decoration-line is also applied, then, if text-
decoration-skip is applied to the <span> element, both lines are affected. However, as of time of writing,
most browsers do not yet support the property, so its effect cannot be demonstrated here, only illustrated.
Table 14.11 lists the values supported, Figure 14.29 shows how the property is used, and Figure 14.30
illustrates the expected result. In the example, the rule says to underline the content of the <p> element and
text-decoration-skip says that the decoration line must skip all descenders. See Figure 13.1 in Chapter 13
for the meaning of a descender.
TABLE 14.11
The Values for text-decoration-skip Property
FIGURE 14.29 Example usage of the text-decoration-skip property.
CHALLENGE 14.20
In what ways do you think the text-decoration-skip property can improve the content of a design?
14.9.3 text-underline-position
The text-underline-position property is used to specify the position of an underline specified on the same
element using the text-decoration property. It does not affect the underline specified by parent elements. It
is inherited and takes the values in Table 14.12. As of time of writing, it is still unsupported by most
browsers. Figure 14.31 shows how it is used and Figure 14.32 shows an illustration (not actual output) of
what the property is intended to do.
TABLE 14.12
The Values for text-underline-position Property
Value Function
auto The browser decides between using alphabetic or under.
alpha- Positions underline relative to the text baseline. This means that the underline is likely to cross descenders. See Figure 14.1 earlier to
betic see what baseline is.
under Positions underline relative to the bottom edge of the content box. This means that it does not cross descenders. It is the type of
underline typically used in accounting documents.
left In vertical writing mode, such as in Eastern Asian text, positions underline to the left. Equivalent to under in horizontal writing mode.
right In vertical writing mode, such as in Eastern Asian text, positions underline to the right. Also equivalent to under in horizontal writing
mode.
FIGURE 14.32 Illustration of the effects the alphabetic and under values.
CHALLENGE 14.21
Given that underline is by default used to represent hyperlinks on Web pages, what are the
implications of using underline for other purposes, and in which situations do you think it might be
more acceptable to do so?
14.9.4 text-emphasis
The text-emphasis property is a shorthand property that allows you to specify emphasis mark for each
character of an element’s text content, except separators and control characters. The size of the mark is
about 50 of the font-size of the text and may affect line spacing, depending on whether or not the current
line spacing is enough for it. The property is especially useful when the text is in languages that use accent
marks, such as Eastern Asian languages. The longhand properties are text-emphasis-style and text-
emphasis-color. The text-emphasis property can be used to specify both. If one is missing, the initial value
is used for it, which is no style for text-emphasis-style and current color for text-emphasis-color. All the
properties are inherited. The value supported by text-emphasis-color is color, which can be specified in
name, rgb(), rgba(), hsl(), hsla(), or hex codes, all of which were discussed in Chapter 9. The values
supported by text-emphasis-style are listed in Table 14.13.
TABLE 14.13
The Values for text-emphasis-style Property
NOTE: Availability of emphasis marks
Note that not all fonts have the characters in the table. Where one is not available on the user’s
system, a “tofu” (a little open box) is displayed. One of the fonts that users could install in their
system to prevent “tofu” is free Google’s Noto family of fonts that is intended to support all
languages and multiple styles and weights. For CJK fonts, the Noto Sans CJK may also need to
be installed.
The third longhand property used in relation to emphasis marks is the text-emphasis-position, which
cannot be specified with the shorthand text-emphasis property. It is inherited and used to specify where to
draw emphasis marks. The values supported are over (which positions the mark over text), under (which
positions it under text), right (which positions it to the right of text in vertical writing mode), and left
(which positions it to the left). As of time of writing, only Chrome, Opera, and Safari support the text-
emphasis properties with -webkit-. Figures 14.33 and 14.34 show how the properties are used and the
result in the Chrome browser.
In the example, the <span> element is used to isolate the Chinese text so that necessary language
information can be provided about it. The <em> element is used to isolate two of the Chinese glyphs for
emphasis styling. The em:lang(zh){} rule applies to the content of the <em> element that has a lang
attribute of “zh” that affects it. These are the two Chinese glyphs. The rule says to make their font style
normal (this removes any style applied by the <em> element, which is typically italic), use a red dot for
emphasis, and place it above each of them. Note that instead of using the dot keyword, the mark can also
be specified using a backward slash and its Unicode as the <string> value, thus: ‘\2022’, so that the
declaration becomes: -webkit-text-emphasis: ‘\2022’ red;. How to use Unicode codes to display
characters with HTML can be found in Chapter 3. Note that the Chinese text was generated using Google
Translate, and then copied and pasted into the code.
NOTE: :dir(identifier)
The :dir(identifier) pseudo-class selector can be used in a similar way as the :lang() selector. For
example, if the dir attribute in an element is set to “ltr” value, the selector can be used to select
the element for styling.
CHALLENGE 14.22
Implement the example, using the filled circle value in Unicode. Also, specify your own single
character, using the <string> value. Furthermore, try enclosing more than one character within the
quotes and see what happens.
CHALLENGE 14.23
One of the main benefits of using the lang attribute is that it lets you style the content by language.
Write the HTML and CSS code to present the content in single quotes below, inserting the lang
attribute as appropriate and using the :lang() pseudoclass selector introduced in Chapter 8 to style
the French text differently from the rest of the text.
“The French phrase for ‘good afternoon’ is ‘bon après-midi’, don’t you know?”
14.9.5 text-shadow
The text-shadow property is inherited and used to add shadows to the text. It takes comma-separated sets
of values, each of which specifies the settings for a shadow. A set comprises four values: the first two
specify the x and y coordinates of the shadow offset, the third the radius of the blur effect (which is
optional and 0 by default), and the fourth the color of the shadow, which also supports transparency
(RGBA). Positive x–y coordinates values move the shadow right and downward. Figure 14.35 shows
how the property is used and Figure 14.36 the effect.
In the example, the p{} rule makes the paragraphs 24px to make them more legible. The .shadow{} rule
specifies two sets of values. The first one says to position the shadow at 1px down and 1px right from the
top-left corner of the box of the <p> element of class=“shadow”, make the radius of the blur effect 2px,
and the color gray.
CHALLENGE 14.24
Implement the example and experiment with the values of the shadows to see how legibility is
affected.
You should notice from the challenge that shadows tend to compromise legibility. For this reason,
adding shadows to the text should be avoided for a lot of text content. On the other hand, adding shadows
to a very short text, such as to the label of a button or icon, can help produce interesting visual effects,
such as embossed effect, that would otherwise require lengthy processes to produce with graphics tools,
which also produce larger image files that can compromise page download and rendering speed. Figure
14.37 shows an example of how the text-shadow property is used in creating button effects and Figure
14.38 shows the result. Notice that various other properties that have already been introduced in this
chapter and previous ones are also used to give the text and its box character.
FIGURE 14.37 Using text-shadow for a button.
CHALLENGE 14.25
Create a button design of your own using the text-shadow property.
CHALLENGE 14.26
Implement the example in Figure 14.39 using your own content. Also, what is the -moz- prefix for in
the p.first::-moz-selection rule?
NOTE: ::marker
It is worth noting that there is also a newer pseudo-element, ::marker, that allows you to specify
custom list-item markers and used with <li> elements. For example, the following rule:
li::marker { content: “(“ counter(counter) “)”; }
...should produce list items that start with (1), (2), (3), and so on. However, the pseudo-element is
not yet supported by any major browser as of time of writing.
FIGURE 14.42 The result of Figure 14.41.
CHALLENGE 14.27
Write the a::before{} rule in the example in Figure 14.41 using longhand properties.
CHALLENGE 14.28
Implement the example in Figure 14.44 but without the line decoration under the link text. Hint:
Refer to text decoration.
14.11.2 :target
The :target pseudo-class allows you to style the element to which a URL points. You might recall from
Section 4.5 in Chapter 4 that it is possible to link to a specific element on the same page using the
#symbol with the href attribute’s value. The :target pseudo-class basically says to select the element
whose id attribute’s value matches the part preceded by the #symbol in the href attribute’s value. For
example, if an href value contains #orange, :target selects the element of id=“orange”. One of the common
applications of the pseudo-class is for making a hidden element appear when a link is clicked. Figure
14.45 shows how it is used and Figure 14.46 shows the result after the link has been clicked.
FIGURE 14.45 Example usage of the :target pseudo-class.
In the example, the #extrainfo{} rule hides the <div> element of id=“extrainfo” (which contains the
<form> element) when the link is clicked, and the #extrainfo:target{} rule shows the element. Note that
once the link is clicked and the target element displayed, the page has to be reopened afresh (not
reloaded/refreshed) for it to work as intended again.
FIGURE 14.50 The result of Figures 14.47 and 14.48 after link is clicked.
The .box{} rule styles the <div> element of class=“box”, which is the element used for the smaller
window that displays the intended content. The rule specifies the size of the element (using width, height,
and padding), positions it at the center of the <div> element of id=“window” (using position, top,
transform, and margin), styles the content (using font-size, font-weight, background-color, and text-align),
and specifies the border and shadow (using border and box-shadow). Note that positioning the smaller
window inside the larger one can be more straightforward by making the elements behave like a table,
using the table and table-cell values with the display property. These values are introduced more fully in
Chapter 17.
The .close{} rule styles the <a> element of class=“close”, which is the control for closing the lightbox
display. Essentially, when the link is clicked, the user is returned to the start of the page underneath. The
rule removes the underline from the element’s content, X (using text-decoration), specifies the size,
weight, and color of X and the background-color and border of the element (using font-size, font-weight,
color, background-color, and border), specifies the shape of the element (using width, height, border-
radius, and padding), and positions the element (using position, top, and left). It is worth noting that the
sizing and positioning of the element is largely through trial and error rather than calculations.
The .close:hover{} rule makes the X black and cursor-shape a pointer when the cursor is over it. The
#window:target{} rule displays the <div> element of id=“window” (hidden in the #window{} rule) as
well as its children (i.e., the smaller window and its content).
CHALLENGE 14.29
A common way lightbox displays are used is to display images. Implement the example, but, instead
of text, display an image.
CHALLENGE 14.30
Implement the example, but without the element that is used to make the current page look dimmed.
CHALLENGE 14.31
If you use the lightbox display to display a form, how would you let the user close the form and at the
same time submit it for processing? Hint: Consider elements and attributes introduced in Chapter 5.
CHALLENGE 14.32
In the .box{} rule in the example, change the value of the position property from relative to absolute,
fixed, and static, respectively, and explain the effects on the positioning of the box and the close
button, based on your understanding of the values from Chapter 12.
CHALLENGE 14.33
Do a search on the Web, using, for example, “css lightbox” as a search term, and study the codes
used for different types of lightboxes.
14.11.3 :not(X)
The :not(X) pseudo-class, known as negation CSS pseudo-class, is a function that allows you to specify
elements that you do not want to be selected for styling. Essentially, it selects elements that do not match
the selector represented by the X (which is known as the argument of the function). Figure 14.51 shows
how the pseudo-class is used and Figure 14.52 the result.
In the example, the p{}rule applies padding to all edges of all <p> elements and the p:not(.middle){}
rule applies a pink background color to the <p> elements that are not of class=“middle”.
CHALLENGE 14.34
In the example, what would the selector :not(.middle) select?
14.11.4 :empty
The :empty pseudo-class allows you to select elements that have no child elements or white space.
Comments or scripts are irrelevant and ignored. Figure 14.53 shows an example of the pseudo-class in
use and Figure 14.54 the result.
In the example, the p{} rule specifies the height, padding, and background color for all <p> elements,
and the p:empty{} rule specifies the background color for empty elements. Notice the white space
between the start tag of the last <p> element and the comment tag. This is why it is not considered empty.
The same result will occur if the white space is between the comment tag and closing tag of the element,
or if there is a carriage return between an element’s tag and the comment tag.
CHALLENGE 14.35
In the example, why is it necessary to specify the height for the p elements?
14.12.1.1 ruby-position
The ruby-position property specifies the position of the ruby text (i.e., <rt> element) relative to the
corresponding ruby base (i.e., <rb> element) and is inherited. Table 14.17 lists the values it takes.
TABLE 14.17
The Values for the ruby-position Property
Value Function
over Places the ruby text above the base text for horizontal script and to the right for vertical and is the default.
under Places the ruby text below the base text for horizontal script and to the left for vertical.
inter-character Places the ruby text between the base text characters.
Figure 14.55 shows how the ruby-position property is used and Figure 14.56 the result. The example
uses the under value. Notice that the HTML code is the same as the one used in Figure 3.46 in Chapter 3.
CHALLENGE 14.36
Implement the example and also make the base text and ruby text of different colors using
appropriate CSS properties from the ones introduced in previous chapters.
14.12.1.2 ruby-align
The ruby-align property allows you to specify how the ruby text in a <rt> element should be distributed
across the base text in the corresponding <rb> element and is inherited. Table 14.18 lists the values for
the property.
TABLE 14.18
The Values for the ruby-align Property
Value Function
start Aligns the ruby text with the start of the base text.
center Aligns the ruby text in the middle of the base text.
space-between Distributes extra space between ruby text characters.
space-around Distributes extra space between and around ruby text characters and is the default.
Figure 14.57 shows how the property is used and Figure 14.58 the result. Note that there must be a
space between the characters of a ruby text in order for some values to have the desired effect.
FIGURE 14.57 Example usage of the ruby-align property.
CHALLENGE 14.37
Implement the example but without any space between the characters in the <rt> elements to see the
effects. Also, give reasons for why having no space between the characters makes some values not
produce the desired alignment.
14.12.1.3 ruby-merge
The ruby-merge property allows you to specify how <rt> elements are rendered when there is more than
one in a <ruby> element and is inherited. Table 14.19 lists the values it takes.
TABLE 14.19
The Values for the ruby-merge Property
Value Function
separate Renders rt elements in the same column as the corresponding rb element and is the default.
collapse Joins together all rt elements and makes them span the corresponding rb element.
auto Makes the browser decide how each rt element is rendered relative to the corresponding rb element.
The property is not yet implemented in any major browser as of time of writing, so, a demonstration is
not possible here, but it is specified in a similar way as the other two.
In the example, the first <div> element and the <span> elements inside it are not converted and so
behave as normal. In contrast, the .ruby{} rule makes the <div> element of class=“ruby” behave like a
<ruby> element.; the .rb{} rule makes the <span> element of class=“rb” behave like an <rb> element; the
.rbc{} rule makes the <span> element of class=“rbc” behave like an <rbc> element, and so on for the rest
of the rules.
CHALLENGE 14.38
Implement Figure 14.59 using the dedicated ruby elements introduced in Chapter 3.
15.1 Introduction
The ability to control the use of images and tailor them to specification is very important in Web design in
order to achieve the desired design goal. CSS provides numerous properties that enable this, including
those for sizing, positioning, and clipping. This chapter introduces the common ones of these properties.
CHALLENGE 15.1
What is the difference between using % and em unit to size an image?
CHALLENGE 15.2
Apart from specifying the image-rendering property because you have scaled images with your code,
for what other reasons would specifying the property be useful? Hint: Consider, for example, user
interaction.
FIGURE 15.5 Specifying the dimensions for responsive images using CSS.
FIGURE 15.6 Specifying the dimensions using both HTML and CSS.
In the example, when a condition is true, the srcset provides the corresponding image source for the
<img> element to embed and the #size{} in the <style> element that matches the condition specifies the
dimensions of the image. If no condition is true, the image source and the dimensions specified in the
<img> element are used.
CHALLENGE 15.3
Implement the examples in Figures 15.5 and 15.6 with your own images and experiment the order of
the <source> elements and see if there are any changes in behavior when the width of the browser is
varied.
See Chapter 8 on more on vendor prefixes. Figures 15.7 and 15.8 show how the property is used and
the effect.
In the example, notice how the parameters for the circle () method are specified. The first specifies the
radius as 30% of the width of the <img> element (i.e., reference box), and the last two specify the x-y
coordinate for the center as 50% of the width from left and 50% of the height from the top. The browser
essentially resolves these percentages from the reference box width and height using a formula. Note that
textual contents too can be clipped.
FIGURE 15.7 Example usage of the clip-path property.
CHALLENGE 15.4
Implement the example using a paragraph of text instead of image and experiment with the
parameters of the circle() method.
CHALLENGE 15.5
Creating polygon clip paths can be difficult. Search the Web for a clip-path generator or maker and
use it to create a polygon clip path (e.g., a star) and then use the code generated with your own
image, using Figure 15.7 as guide.
The img{} rule in the example sets the width and height of the image, changes the <img> element to a
block-level element, and sets the right and left margins. Note that a declaration using the margin shorthand
property (thus: margin: 0 auto) will produce the same result.
CHALLENGE 15.6
The declaration margin: 0 auto; will produce the same result as using the longhand properties used in
Figure 15.9. How?
CHALLENGE 15.7
Implement the example in Figure 15.9, but with your image contained in a <figure> element, bearing
in mind that the element is a block-level element.
15.6.1 object-position
The object-position property lets you specify the position of an image (or any object, including video)
relative to the edges of the element’s box. It is inherited and the values it takes are x-y coordinates of
where to position an image. The values are expressed in length values and can be in absolute length units
(e.g., px), box-relative lengths (i.e., %), font-relative lengths (e.g., em), or viewport-percentage lengths
(e.g., vh and vw). Positive values move image toward the right or bottom, and negative toward the left or
top. Figure 15.11 shows how the property is used and Figure 15.12 the result.
In the example, the img{} rule specifies the size of the <img> element, the border width, style and
color, the background color, and right margin to put some space between the images. The .obj ect-
position{} rule positions the <img> element of class=“object-position” 60px from the left edge of the
element’s box and 30px from the top edge. Notice that the background of the image is transparent and that
is why the element’s background color is visible.
CHALLENGE 15.8
Implement the example, but with an image that has a non-transparent background in order to see the
relationship between the background of the element and boundaries of the image.
15.6.2 object-fit
The object-fit property allows you to specify in a number of ways how the content of an element should
be made to fill the element’s content box. Its effect depends on the difference between the aspect ratio of
the content and the aspect ratio produced by the specified dimensions for the element’s content box.
Aspect ratio is the ratio of width to height (i.e., width:height). The property is non-inherited and the
values it takes are listed in Table 15.3. Figure 15.13 shows how the property is used and Figure 15.14 the
effects of the values (not the output of Figure 15.13).
Notice in the example the large differences between the outputs of the values. This is because the
aspect ratio of the image (content) is significantly different from that of the element’s content box. The
actual size of the image is 800 x 536 pixels, making its aspect ratio 1.49:1 (i.e., 800:536), while the size
of the element’s content box is 200 x 70 pixels, making its aspect ratio 2.86:1 (i.e., 200:70). The
reference image represents the image displayed without object-fit.
TABLE 15.3
The Values of the obj ect-f it Property
Value Function
fill Makes content fill the element’s content box and may stretch content.
contain Makes content retain aspect ratio as well as fit it within the element’s content box, which means content may not fill element’s
content box.
cover Makes content retain aspect ratio as well as fill the element’s content box, which means content may be clipped at the edge.
none Content is not resized to fit in the element’s content box. The box simply shows the area of the image its size spans.
scale- Sizes content as if none or contain is specified, depending on which value makes the content smaller.
down
FIGURE 15.13 Example usage of the obj ect-fit property.
FIGURE 15.14 The effects of the values of the obj ect-fit property. (Image from www.freeimages.co.uk.)
CHALLENGE 15.9
Implement the example, using your own image, and then experiment with the aspect ratio of the box
to see the effects to better understand how to use the property.
FIGURE 15.15 The 512 x 512 image used for background. (Image from www.subtlepatterns.com.)
Figure 15.16 shows how the background-image property is used and Figure 15.17 the result. In the
body{} rule, background-image says to use the image, “wood.png,” found at the location specified by the
url () method for the background of the <body> element and padding specifies the space between the
content of the element and its border.
Figures 15.18 and 15.19 show the same image used in the previous example in the <p> element instead
of in the <body> element. A similar effect will be obtained with the <div> element.
CHALLENGE 15.10
What effect would different values of the width and height properties have on the size of the
background image and the content of a page and why?
CHALLENGE 15.11
As noted in Chapter 6, the most common use of images for backgrounds is for decoration. What are
the useful considerations you need to make when using background images, especially in terms of
contrast, legibility, aesthetics, performance, etc.?
Figure 15.23 shows the result of the code in Figure 15.21 when repeat-y is used instead of repeat-x, so
that the declaration becomes background-repeat: repeat-y.
CHALLENGE 15.12
To produce the example in Figure 15.23, an extra rule was added to the code in Figure 15.21 to make
the background of the <h1> and <p> elements white so that their contents are legible on the image.
Rewrite the example to reflect this.
Notice that there are 12 images in the first example, while there are 13 in the second, yet the width of
the browser is the same in both cases. In the first, the images are equally spaced to cover the browser’s
width to avoid clipping the last one, while in the second the images are scaled down and another added to
prevent it.
CHALLENGE 15.13
In what categories of websites might you use background images that are shown in the example and
why?
In the example, the div{} rule applies to all the <div> elements. The border property makes the borders
10px-thick solid line and grey; padding specifies the space between their content and their border;
background-image specifies the image to use for their background (i.e., club.jpg); and background-repeat
says to repeat the image only along the x-axis. The #border{}, #padding{, and #content{} rules say to
place the specified image at the top-left corner of the border box, padding box, and content box of the
elements, respectively, from where it is then repeated.
CHALLENGE 15.14
Implement Figure 15.28 with the images aligned vertically.
CHALLENGE 15.15
In the first two <div> elements, there seems enough space between the content and the left and right
edges of the background color. How would you create the same thing in the third <div> element?
CHALLENGE 15.16
In the example, replace the plain background with an actual image.
In the body{} rule in the example, background-image specifies the image to use for background,
background-repeat says to repeat the image across the x-axis, and background-size says to resize it to 80 x
80. The hl, h2, p{} rule horizontally centers the content of the <h1>, <h2>, and <p> elements. Note that
the auto and percentage values can be specified the same way as px. The example also displays the image
in its actual size using the <img> element.
CHALLENGE 15.17
Rewrite the code in Figure 15.32 using your own image so that the heading is not on the repeated
image but under it and the positions of other texts are adjusted accordingly. Also, what do you think
the design benefits are of this modification?
Figure 15.35 shows the result of Figure 15.33 with the value of the background- size property changed
to contain in the .cover{} rule. The resulting rule therefore says to scale the background image so that it is
contained in the element, which means part of the container is left unfilled.
FIGURE 15.35 The result of Figure 15.33 using the contain value. (Image from www.freeimages.co.uk.)
CHALLENGE 15.18
Rewrite the code in Figure 15.33 to make it more efficient and say why it is more efficient.
CHALLENGE 15.19
Rewrite the code in Figure 15.33 so that the effects of cover and contain are shown together on the
same page.
In the div#multi{} rule, the width and height properties specify the size of the <div> element of
id=“multi”, the background-image property specifies the two images (“rose_transparent.png” and
“grey_wall.png”) to use for its background (the first image occupies the top-most position and the last the
bottom-most), the background- repeat property says the first image should be repeated across the x-axis
and the second not repeated, and the background-size property says to make the size of the first image 60 x
60px and use the cover value for the second. Note that the image specified first is displayed on top.
Also, the images on top must have transparent background in order for those underneath to be visible.
This means that they must be saved in a file format that supports transparency (e.g., png).
In the div#inner {} rule, the width property specifies the width of the <div> element of id=“inner”, the
padding property centers the element, both horizontally and vertically, inside the <div> element of
id=“multi”, and color says to give the text content #F9F0B5 color. The h2{} rule centers the content of the
<h2> element horizontally.
CHALLENGE 15.20
Implement the example using your own images and modify the code so that it also has the smaller
image repeated vertically. Also, state for what types of websites such design would be acceptable
and why.
In the example, the background-image property specifies the image to use for the <body> element’s
background, the background-repeat property says not to repeat it, the background-attachment property says
to make its position fixed, and padding specifies the space between all the contents of the <body> element
and the border of the element’s box. In Figure 15.39, notice that the heading is scrolling off screen while
the background image remains at the top-left corner of the window.
CHALLENGE 15.21
What types of images usually benefit best from being fixed as shown in the example? Give reasons
for your answer.
Figure 15.43 shows how the same example in Figure 15.41 and Figure 15.42 can be achieved with
percentage values. The values represent, respectively, the horizontal and vertical distances from the top-
left corner of the browser window, which is 0% 0%. So, 50% 50% specifies a position that is 50% of the
browser’s width and 50% of the height from the top-left corner.
FIGURE 15.43 Using % values in Figure 15.41 to achieve Figure 42.
CHALLENGE 15.22
From design principles point of view, say why using an image as in the example may not be good
practice and also say how to minimize any adverse effects of using images in this way. Hint: See
Decorative images in Chapter 6.
In the example, the background property specifies the background- color, background-image,
background-position/background- size, background-repeat, and background-clip properties for the <p>
element, the border property says to make its border 10px-thick dotted line and black, and the padding
property specifies the space between the content of the element and the border.
CHALLENGE 15.23
Implement the example in Figure 15.45, using your own content, but with the image positioned
center-bottom in a <div> element and the text in a <p> element. What do you think are the pros and
cons of both design approach? Hint: Varying the browser width for both approaches may give you
some additional ideas.
CHALLENGE 15.24
Would using the background property twice produce the same result as in the example? If not, why?
16.1 Introduction
The use of images to create visual effects is standard practice in Web design. Image effects are essential
in creating interactivity, such as in rollover effect, and some, such as gradients, filters, and image
blending, can be useful for adding aesthetics to a page. In this chapter, some of the CSS properties used in
creating image effects are introduced.
FIGURE 16.2 Code for displaying the button sprites in Figure 16.1.
FIGURE 16.3 The results of Figure 16.2.
To display the active-state sprite when the inside of the <a> element is clicked, the a#register:
active{} rule moves the image up 120px (i.e., −120px) so that coordinate 0px 120px on it (where the
active-state sprite starts) aligns with the top-left corner of the box and also specifies a height of 50px.
Note that moving an image up or left requires a negative value, while moving it down or right requires a
positive value.
CHALLENGE 16.1
Use a graphics editor, such as Photoshop or GIMP, to create your own icon or button sprites and use
them to create an interactive icon or button, using the code in Figure 16.2. Alternatively, or in
addition, you could search the Web for “CSS sprites generators” and use one to create the sprites.
CHALLENGE 16.2
Add a border declaration to the a.button{} rule in your implementation from the previous challenge
to show the border so that you can see the relationship between the placement of the sprite and the
<a> element’s box. Also, try reducing the width and height of the element to see how much of the
image is shown.
CHALLENGE 16.3
The code in Figure 16.2, or your implementation, can be made more compact by combining some
rules. Which and how?
So, in the #register{} rule, the background-image property specifies the image to use for the
background of the <input> element, the width and height properties specify the element’s size, and the
background-position property positions the image at the top-left corner of the element’s box. The
#register:hover{} and #register:active{} rules perform exactly the same functions as described for Figure
16.2. It is in the HTML code that the most important change is made. Notice there that another image is
specified for the <input> element. This is because the element requires that an image is specified,
otherwise a default label or the alternative text is displayed, depending on browser. This means that if no
image is specified, the text is displayed on the specified background image, and if an image is specified,
it is similarly displayed on the background image. To work around this, a transparent image is specified.
This is an image that contains nothing and has a transparent background. The image can be any size, since
it is only symbolic, but should be as small as possible for obvious download performance reasons. The
one used in the example is 5 × 5px. Common image formats that allow a transparent background include
PNG and GIF.
CHALLENGE 16.4
In the example, why does the amount of space occupied by the transparent image on the rendered
page not depend on the size of the image? Also, specify the same image for the src attribute as
specified with the background-image property to better understand why the transparent image
workaround is necessary.
16.4 Gradients
Gradients work on the general basis of an imaginary line that has a start and an ending. Each point on the
line has a different color and defines the color of the gradient that runs through it. A specified color starts
at a specified point on the line, known as a color stop, and gradually changes to another that is specified
at another stop. In theory, there can be as many stops as possible and the shape of a gradient can be linear
or radial. Figure 16.5, which is the type of graphical interface used in graphics programs to create a
gradient, illustrates this basic principle. The image shows both the stops, for colors and the opacity (i.e.,
transparency). The stops at the bottom are for the colors, and those at the top are for the opacity for each
stop. The gradient starts with orange, gradually changes to black, then to orange, and then black. CSS can
be used to specify the various parameters for creating gradients in this way.
Gradients are seldom used in the design of a Web page. This is because they are mostly suitable for
adding visual effects, and adding visual effects to a whole page is not usually desirable, especially
because gradients can compromise legibility. However, gradients are commonly used in buttons and icons
to help add the illusion of depth to them. CSS supports both linear and radial gradients, and the properties
used to create them are the background-image property or the shorthand background property.
CHALLENGE 16.5
Implement the example in Figures 16.6 and 16.7 and experiment with the values to better understand
how linear gradient works.
The values used in the rules are mostly similar to those you already saw in the previous examples. The
div{} rule specifies the size of box and the span{} rule the color of the text and its background to ensure
good enough legibility. The #grad1{} rule creates a gradient that goes in 180° direction (i.e., top to
bottom), starting with gray, then gray again for 7% and black for 15%. This sequence is then repeated for
the height of the box. The #grad2{} rule specifies gradient that goes in 45° direction (i.e., bottom-left to
top-right), starting with black, changing to white after 20px, and going on for 50px. This sequence is
repeated for the width of the box. The #grad3{} rule specifies −45° direction (i.e., bottom-right to top-
left), starting with the transparent keyword (i.e., rgba(0,0,0,0)), changing to black after 20px, and white
after 50px. Various patterns can be created by adjusting the value of the stops, number of transparent
keyword, and the transparency of colors, using RGBA or HSLA.
CHALLENGE 16.6
Why is it necessary in the example to use the <span> element for the purpose described, instead of
just including the declarations in the span{} rule in the div{} rule?
CHALLENGE 16.7
Implement the example with various other colors and experiment with the positions to see the
obscure effects of the repeating-linear-gradient() function.
CHALLENGE 16.8
The screenshot below is an example application of repeating linear gradient and the gradient pattern
is created using the #grad1{} rule in Figure 16.9. The challenge is to write a code to create the
design (using different colors, if you like). Also, in what other ways might you use repeating linear
gradient in a design and what are the important considerations with using it or other types of
patterns?
CHALLENGE 16.9
Implement some of the gradients in the example and experiment with the parameters.
CHALLENGE 16.10
What are the important things to bear in mind when using gradients as background in terms of how
usable a page is?
CHALLENGE 16.11
Create a design with the repeating-radial-gradient() and state for what type of site it might be
suitable.
CHALLENGE 16.12
Complex gradients can be produced by using more of the background properties, especially
background-size. For example, adding backgroundsize: 30px 30px; to the #grad5 rule in Figure 16.7
or the #grad1 rule in Figure 16.9, or the #gradient7 rule in Figure 16.12 will change the gradient
patterns produced. Give these a try and also experiment with various values to form further
understanding about how CSS gradient works.
16.5 Filters
Image filters are image processors that make it possible to achieve various visual effects with an image,
similar to some of those achievable in Photoshop and other graphics programs, such as blurring and color
manipulation. The property used to implement these effects in CSS is the filter property. It can be useful
for adding effects to a background or border. It is non-inherited and the values it takes are functions that
take parameters that specify what to do to produce the desired effects. Different functions take different
parameters and the property can take multiple space-separated functions. Table 16.3 lists the functions
supported and what they do.
Table 16.3 Values Supported by the filter Property
Figures 16.18 and 16.19 show how the filter property is used. The <img> attribute specifies the target
image and the img{} rule two filter functions: hue-contrast() and saturate(). The first says to apply hue
rotation at 90° and the second 190% contrast, resulting in the color and contrast of the image being
changed. The -webkit- declaration is for browser that only supports the property via webkit. See the note
on vendor prefixes in Chapter 8 for more on the prefix.
FIGURE 16.18 Using the filter property.
CHALLENGE 16.13
Implement the example using your own image and experiment with the various functions to see how
they can be useful.
16.6.1 background-blend-mode
The background-blend-mode property allows you to specify how an element’s background image blends
with the one below it and the element’s background color, including gradient. The content behind the
element is unaffected. The property is non-inherited and takes one value, which specifies the blending
mode to apply. Figure 16.20 shows an image and the available CSS blending modes and their effects on a
gray background color. The normal blending mode is the default and shows the actual appearance of the
image.
FIGURE 16.20 Blending modes and their effects for a specific image and background.
Figure 16.21 shows how the background-blend-mode property is used. It is the code used to produce
the examples in Figure 16.20, with the value of the property changed as necessary. Note that the
background of the image is transparent. In the example, the background-image property specifies the
background image for the <body> element, background-repeat says not to repeat it, background-color
specifies a gray background, and background-blend-mode specifies the multiply blending mode.
When multiple blending modes are specified, they are applied in the same order as the images
specified by the background-image property. The image specified first occupies the topmost layer. This
means that in Figure 16.22, overlay specifies how the first gradient blends with the second; multiply
specifies how the second gradient blends with the third; screen specifies how the third gradient blends
with the first image; difference specifies how the first image blends with the second, and because no
value is specified for how to blend the second image with the third, the browser starts from the beginning
of the list of values again, that is, it uses overlay. Figure 16.23 shows the effect of the code. Note that
changing the order in which the images are specified will also change the blending result.
FIGURE 16.21 An example of how the background-blend-mode property is used.
CHALLENGE 16.14
In the example in Figure 16.22, if you specify a background color for the <body> element, how will
it affect the blending of the images in the <div> element, and why?
16.6.2 mix-blend-mode
The mix-blend-mode property allows you to specify how an element’s content should blend with the
content and background of the element below it. It is non-inherited and, like the background-blend-mode
property, takes one value, which is the blending mode to apply and can be any of those in Figure 16.20.
Figure 16.24 shows how the property is used and Figure 16.25 the result.
FIGURE 16.24 Example of how the mix-blend-mode property is used.
In the example, the div{} rule specifies the background image; says not to repeat it; says to center any
content of the <div> element; and specifies the size of the element to make it the same as that of the
background image so that when content is centered in the element it is also centered in the background
image. The img{} rule blends the image specified in the <img> element with the background image.
CHALLENGE 16.15
What will happen if the mix-blend-mode:overlay declaration is placed in the div{} rule instead of
the img{} rule, and why?
16.6.3 isolation
The isolation property is usually used in conjunction with the mix-blend-mode property and allows you to
isolate elements from a group of blended elements. It is non-inherited and the values it takes are auto
(which means no isolation, and is the default) and isolate (which says to isolate element from blend
group). Figure 16.26 shows how it is used and Figure 16.27 shows the result when isolation is not used
and when it is used. The div{} rule positions the images at the same point to make them overlap. The
img{} rule blends all the images, and the .three{} rule isolates the third (bottom) image.
FIGURE 16.26 Example usage of the isolation property.
CHALLENGE 16.16
Implement Figure 16.26, using your own images, and experiment isolating different elements to see
the effects and learn more about how the isolation property works.
CHALLENGE 16.17
Use the :hover pseudo-class discussed in Chapter 14 with the code in Figure 16.26, so that the image
is isolated only when the cursor hovers over it. Also, can you think of situations in which you might
use the isolation property?
17.1 Introduction
Lists, tables, and forms are created using special types of HTML elements introduced in Chapters 4 and 5.
Although some of the CSS properties encountered in the previous chapters can be used to style the
contents of these elements, CSS also provides properties that are designed specifically for controlling the
formatting and styling of the elements. In this chapter, both the generic and element-specific properties are
discussed.
17.3 Lists
The four properties used to format and style the contents of list elements are list-style-type, list-style-
position,list-style-image, and list-style.
17.3.1 list-style-type
The list-style-type property is used to specify the shape or style of bullet points (or markers) and can be
used with <ul>, <ol>, or <li> element. The property is inherited and the values taken depend on whether
it is used to style an unordered (<ul>) or ordered (<ol>) element. Table 17.1 lists the values and Figures
17.1 and 17.2 show how it is used and the result.
TABLE 17.1
Values Supported by the list-style-type Property
FIGURE 17.1 Example usage of the list-style-type property.
CHALLENGE 17.1
Write a code to produce the following list:
There are three types of items:
A. Item number 1, which in turn contains 2 smaller items:
i. Smaller item 1
ii. Smaller item 2
B. Item number 2
C. Item number 3
17.3.2 list-style-image
The list-style-image property allows an image to be used as a bullet point. It is inherited and takes two
values: url() (which specifies the location of image) and none. Figures 17.3 and 17.4 show how the
property is used and the result. The url() value says that the image (oval.png) to use for the bullet point is
in the “images” folder.
CHALLENGE 17.2
For which of the following types of websites do you think using list-style-image is likely to add to
user experience and why? Also suggest the style you think would be appropriate.
Financial
Kids
Fashion
Religion
CHALLENGE 17.3
Add a border to the <li> elements to show which side of the list-element box the marker is placed.
17.3.4 list-style
The list-style property is shorthand for specifying list styles. It is inherited and used to specify list-style-
type, list-style-image, and list-style-position properties all at once in any order. In theory, list-style-type
and list-style-image would not be specified together, since you cannot have two different things as a
marker. Figure 17.7 shows how the property is used and says to use a square marker and place it inside
the list-item box. Figure 17.8 shows the result.
CHALLENGE 17.4
Rewrite the code in Figure 17.7, using longhand properties. Also, state the difference between
specifying width for the <ul> instead of the <li> element; and what would happen if width is not
specified at all for the list.
FIGURE 17.9 HTML for styling an ordered list with generic properties.
FIGURE 17.10 CSS for the HTML in Figure 9.
FIGURE 17.11 The result of Figures 9 and 10. (Image from http://www.freeimages.co.uk.)
CHALLENGE 17.5
Implement the example, using your own image and content, then experiment with different values for
the properties, especially padding, list-style-position, and border style.
CHALLENGE 17.6
Using the discussion of :nth child pseudo-classes in Chapter 8 as guide, explain how the li:nth-
child(2n+1) {} rule in the example styled only the borders of alternate <li> elements.
CHALLENGE 17.7
Modify the code in Figure 17.12 so that the definitions are not indented right.
CHALLENGE 17.8
Implement the example and also use some of the list-specific properties to further format and style
the list items.
17.4 Tables
Like lists, tables are styled using generic properties as well as properties designed specifically for styling
the features of a table.
In the example, the body{} rule specifies the font, color, and size to use for all text in the document.
The table{} rule says to put space of 0.5 em between table and the edges of the window. The td, th{} rule
specifies 0.4 em space between the content of the table cells and their borders, and makes the borders
solid and black. The th{} rule makes the headers all-caps, spaces them a little to make them more
distinguishable, aligns them left, and makes the bottom edges of the borders thicker than those of the data
cells to visually separate the headers from the data cells. The tr.dkfrey{} rule specifies a background
color for the headers, and the tr.grey{} rule specifies background color for <tr> elements of class=“grey”
to create alternating and contrasting rows for easier reading.
CHALLENGE 17.9
In the body {} rule in the example, what is the font size 100% of, and what would happen if it is not
specified? Also, why is the <th> element aligned left and the <td> element not?
CHALLENGE 17.10
The alternate background colors of the table rows can also be created using the :nth-child expression
shown earlier in Figure 17.10. Use this to implement the same effect as in the example in Figure
17.18.
CHALLENGE 17.11
This challenge was first presented in challenge 4.5 in Chapter 4. Center the content of the data cells.
NOTE: Content wrapping in tables
The properties discussed in for controlling content overflow in an element’s box, such as
overflow, white-space, text-overflow, and hyphens, can also be used to control overflow in table
cells.
17.4.2.1 border-collapse
The border-collapse property is used to specify whether the borders of adjacent table cells should be
separated or combined into one. It is inherited and the values it takes are separate (which is the default)
and collapse. Figure 17.19 shows the output of Figure 17.17 after the border-collapse: collapse;
declaration has been added to the table{} rule, so that it looks like this: table { margin: 0.5em; border-
collapse: collapse; }. Notice that the borders of the cells are now represented with single lines.
CHALLENGE 17.12
What is the effect of the padding property on the table cells, and how is this compared with the effect
on the whole table?
FIGURE 17.19 Shows Figure 18 after the cell borders are collapsed.
17.4.2.2 border-spacing
The border-spacing property allows you to specify the space between table cells when the value of the
border-collapse property is “collapse.” It is inherited and the value it allows is the length value (e.g., px
and em). When a single value is specified, it is used for both horizontal and vertical borders. When two
values are specified, the first is used for horizontal spacing (which is the space between the cells of
adjacent columns) and the second is used for vertical spacing (which is the space between the cells of
adjacent rows). Figure 17.20 shows the result of the code in Figure 17.17 after the borderspacing: 5px
20px; declaration is added to the table {} rule so that it looks like this: table{ margin: 0.5em; border-
spacing: 5px 20px; }. It says to make horizontal spacing 5px and vertical 20px.
CHALLENGE 17.13
Interesting and aesthetically pleasing effects can be produced by large border width values and color
transparency. Implement the example in Figures 17.16 and 17, using your own content if more
convenient, and experiment with these properties and also 0px horizontal spacing, for example.
17.4.2.3 empty-cells
The empty-cells property is used to specify how the borders and backgrounds of cells that have no visible
content should be rendered. It is inherited and the values it takes are show (which displays the borders of
empty cells and is the default) and hide (which makes the borders of empty cells invisible). Figures 17.21
and 17.22 show how the property is used and the effects.
CHALLENGE 17.14
What would happen if all cells in a row are set to hide and have no visible content?
17.4.2.4 table-layout
The table-layout property is used to specify how the browser determines the width of the cells of a table.
It is non-inherited and the values it takes are auto (which is the default) and fixed. When value is auto,
the width of cells depends on their content. When it is fixed, the width of cells is fixed and the same for
all cells. The fixed method is supposed to make tables render faster than the auto. Figure 17.23 shows
how the property is used and Figure 17.24 the result. Notice the differences in the widths of the cells and
how content is wrapped in the fixed layout when it is longer than the width.
CHALLENGE 17.15
Using your own content, implement the example in Figure 17.23 to know more about the effects of
auto and fixed values.
In the example, normal <div> and <span> elements are converted to table elements. The .table{} rule
makes the <div> element of class=“table” a <table> element; the .head{} rule makes the <div> element of
class=“head” a <tr> element and styles the content and background; the . row{} rule makes the <div>
element of class=“row” a <tr> element; and the .cell{} rule makes the <div> element of class=“cell” a
<td> element.
CHALLENGE 17.16
Implement the example and remove the formatting and styling to see how the content is displayed
without them.
17.4.4 Guidelines for Designing Effective Tables
A table should be easy to understand and scan, and this goal is achieved through effective formatting and
styling, which can be done using both generic and table-specific CSS properties. The following are some
guidelines.
Make table aesthetically pleasing to make it easy to read. This can be achieved through making
a table as simple as possible and using ample space, such as ample padding.
Aid comprehension of data: This can be done through using meaningful caption and headings and
avoiding abbreviations or acronyms. If abbreviations or acronyms are used, one or two sentences
of explanation should be provided, typically as footnotes.
Structure data to match table’s purpose: For example, if the purpose is to compare the quantity
of things produced by different sources (e.g., countries), it is better to organize data by quantity,
such as from smallest to largest, or vice versa, than alphabetically. On the other hand, if the
purpose is to communicate changes in quantity over time, then it is better to organize data based
on time than on quantity.
Include only important data in order to avoid a cluttered table that has everything but is difficult
to read and understand. For example, only totals might be included instead of also including all
the components that make up the totals.
Make use of visual hierarchy to communicate levels of importance to facilitate scanning. This
can be done using font style, font size, font color, and font weight. For example, headings should
be in larger font size and bolder weight and data that needs to be emphasized can be made bold or
given a different color from the rest of the data.
Round data to integers, unless presenting them in decimal points is important to their
understanding. This is because rounded numbers are usually easier to compare. Where decimal
numbers are used, it is generally recommended that no more than one decimal place is used,
because the more there are, the harder it is to determine which values are lower or higher.
Perform necessary calculations for the user, because it is hard to hold the result of one
calculation in memory while doing another calculation for comparison. For example, if reference
is made to the sum of the data in a row or column, it is helpful to provide an additional row or
column for presenting it.
Ensure consistency, both in appearance and in communicating data meaning. The way specific
messages are communicated should be consistent. For example, if a color is used to indicate
values that are above a specific level, it should be used for the same purpose throughout the table
and, also, no other color should be used for the same purpose.
Ensure there is enough contrast between foreground and background to aid legibility.
Group similar data, where applicable, to facilitate the scanning and comparison of data. This
can usually be done using background color.
Make use of gridlines to structure and separate data for easier comprehension. This can be done
through the use of different line thicknesses and/or shades of colors. For example, the lines
enclosing a row that contains totals might be made bolder.
17.5 Forms
Forms, as mentioned in Chapter 5, are essential for collecting information from users. It is also important
that they are made easy to complete and attractive. This can largely be achieved by grouping and ordering
fields in a logical way and properly aligning them. You would have already seen in Chapter 5 how form
elements can be grouped into sections using, for example, the <fieldset> element. Here, how to style these
elements is shown. Figure 17.27 shows the HTML code for a form and Figure 17.28 shows the result
without CSS styling.
Notice in Figure 17.27 that unlike the ones in Chapter 5, the <div> element is used to contain the form
controls. This is to make it easy to apply styling to them, for example, as a group. Also, notice in Figure
17.28 that the controls and the labels are not aligned and slightly packed too closely together. The main
goal of formatting and styling here is to improve this appearance. Figure 17.29 shows the CSS for doing
this and Figure 17.30 the result.
In the example, the form{} rule sets the form’s width with the width property. In the fieldset{} rule,
border property sets the border of the <fieldset> element to solid line and #c6c4c4 color; the border-
radius property makes the corners of the box round. In the legend{} rule, text-transform makes the content
of the <legend> element all-uppercase; background-color makes its background #e4f0f6 color; border
makes its border solid line and #d4d4d4 color; border-radius makes its corners round; and padding
specifies the space between its content and the top and bottom edges as 5px and between the right and left
edges as 15px. The div{} rule specifies 10px margin for every <div> element so as to add space between
the form controls and produce a more spacious and easy-to-read form.
The .box{} rule specifies background color for the elements of class=“box” (i.e., the text-input boxes)
in order to make them stand out. The .field{} rule vertically aligns the text-input boxes and the labels. In
it, the float property moves all elements of class=“field” (i.e., the <label> elements for the text-input
boxes and the radio buttons) left; the width property makes their width the same, so that their left and right
edges, and the left edges of the text boxes, are vertically aligned; the text-align property aligns the
elements’ contents to the right, so that their ends are vertically aligned; and the padding-right property
adds padding to the right edges of the labels to put some space between them and the text-input boxes. The
.moveleft{} rule removes the padding around elements of class=“moveleft” (i.e., the radio buttons) so as
to vertically align the first one with the left edges of the text-input boxes. The .buttons{} rule aligns the
element of class=“buttons” (i.e., the element containing the submit and reset buttons) to the right of the
<fieldset> element’s box.
FIGURE 17.27 The code for the form to style.
CHALLENGE 17.17
How else would you create the space between the labels and the input boxes apart from using the
padding property?
FIGURE 17.33 The result of Figures 31 and 32 (Icons by Ednes Dal [username], and Popcic [e-mail and password]).
In the example, the form{} rule specifies the width of the form. In the field-set{} rule, border makes the
border of the <fieldset> element a solid line of 1px thickness and gives it #c6c4c4 color; border-radius
makes the corners of the element’s box round; and padding makes space between the content of the
element and the border 15px. The div{} rule specifies a margin of 15px to add space between the form
controls so that they are not too close together. The .field{} rule vertically aligns the text boxes. The
width property makes all elements of class=“field” (i.e., <label> elements for the input boxes) the same
width to align them vertically; the float property moves them to the left of the <fieldset> element; and text-
align aligns their content right to vertically align them. The .button{} rule aligns elements of
class=“button” to the right.
The .box{} rule specifies the width, border, background-color, margin-left, and padding properties for
the elements of class=“box” (i.e., username, e-mail, and password input text boxes). The margin-left
property adds space between the input boxes and their labels. The padding for the left side is set to 30px
to ensure clearance in the boxes, so that when users enter data, the data does not go on top of the images.
The .username {} rule uses the background property to specify the background image to place in the
box (i.e., username.png), and not to repeat it. It also specifies the background color for the box and the x-y
coordinate for where to place the image. The first value specifies the horizontal position and says to place
the image at 3% of the length of the element’s box, starting from the left edge. The second value specifies
the vertical position as 50% of the height of the element’s box, starting from the top edge. The background
property is shorthand property for specifying various longhand background properties and was discussed
in Chapter 15.
The .email{} and .password{} rules specify similar properties and values as the .username{} rule but
use different images. The size of the images is 16 x 16 pixels. However, bigger images can be used and
scaled down accordingly using the background-size property to specify the width and height. This
property too has been introduced in Chapter 15. Note that to avoid repetition and make the code more
elegant and easier to maintain, the properties and values that are common to the three rules can be placed
in the .box{} rule, since all the text input elements belong to class=“box”.
CHALLENGE 17.18
Implement the example in Figures 17.31 and 17.32, using your own images, and placing the
properties and values common to the .username{}, .email{}, and .password{} rules in the . box{}
rule to remove the repetitions.
CHALLENGE 17.19
Implement the example in Figure 17.35 and then modify the code to align the controls, using the
principles introduced in Figure 17.29.
In the example, the input#button{} rule applies to the <input> element of id=“button” and determines
the appearance of the button in the normal state. The width and the padding properties specify the size of
the button; background-color specifies #ffcc66 color; border-radius makes the corners of the button round;
box-shadow property specifies a dark gray shadow that has an x-y-offset of 3px 3px, a blur-radius of 2px,
and no spread-radius (See for more on box shadow); and the rest of the properties in the rule specify the
styling for the button text, including text shadow. The input#button:hover{} rule applies to the <input>
element of id=“button” that has the cursor over it and says to change text color of the element (the button)
to blue and its background color to orange.
CHALLENGE 17.20
Using the principles in Figure 17.36, write a code to create an interactive button that has the normal,
hover, and active states. The pseudo-class for the active state is :active, as shown in Table 14.16 of
Chapter 14.
17.5.2.2 Styling Default Button
When the browser displays a group of associated elements, it makes one of the elements the default. In the
case of a group of buttons in a form, for example, the default element is typically the first element of
submit type. CSS allows you to select and style this element using the :default pseudo-class. Figure 17.38
shows how it is used and Figure 17.39 the result.
In the example, the form{} rule specifies the size of the <form> element. The div{} rule specifies the
margin for all four sides of the <div> elements to put some space between the form controls and the edges
of the <fieldset> element. The .box{} rule styles and formats the <input> elements of class=“box” (i.e.,
the textboxes). The .buttons{} rule aligns the <input> elements of class = “box” (i.e., the buttons) to the
right. The :default{} rule makes the border of the default button 2px thick solid line and green.
CHALLENGE 17.21
In the code below, which element will the :default pseudo-class select and why?
<form>
<p><input type="text" name="lname"></p>
<p><button type="submit">Search</button></p>
<p><input type="button" value="Submit"></p>
<p><input type="reset"></p>
</form>
17.5.3 Specifying Cursor Shape
When rollover is implemented, it is also good practice to change the shape of the cursor during the hover.
The property used for this is the cursor property and it is used to specify the type of cursor to display
when the mouse is over an element. It is inherited and takes many types of values that describe a shape.
Table 17.4 lists some common ones.
Figure 17.40 shows the hover state for the same button in Figure 17.37 but with the cursor shape
changed to a pointer.
TABLE 17.4
Values Supported by the cursor Property
CHALLENGE 17.22
Implement the code in Figure 17.36, or your own design, and also add the declaration,
cursor:pointer, to the appropriate rule to create a button that behaves like the one in Figure 17.40 in
hover state.
The input:out-of-range{} rule says that the border of any <input> element whose value attribute’s value
is outside 1-10 should be 2px solid line and red.
CHALLENGE 17.23
In the example, what would happen if “input” is not included in the selectors, so that, for example,
input:in-range{} becomes :in-range{}? Also give the reason for your answer.
In the example, the input:valid{} rule says to make the border of <input> elements whose content
contains only numbers 2px thick solid green line. The :input:invalid{} rule says to make the border of
<input> elements whose content contains a non-digit 2px thick solid red line.
CHALLENGE 17.24
Again, in the example, what would happen if “input” is not included in the selectors, so that, for
example, input:valid{} becomes :valid{}? Also, give the reason for your answer.
18.1 Introduction
Animation in the serious sense is generally outside the scope of Web design. Typically, animations, such
as of a story or process, would be created using other programs, after which the file is incorporated into
HTML. However, basic animations, such as rollover effects used with buttons and icons to communicate
a system’s response to user interaction, are part of Web design and it is for these that the animation
properties provided by CSS are primarily suited. Most other types of animation are difficult to put to
effective use in Web design. This chapter introduces the animation properties.
Tweening can also be in the form of changing one shape into another, sometimes known as shape
tweening. This principle is illustrated in Figure 18.2 and typically involves specifying two shapes and
letting the computer fill in the in-between shapes.
CSS enables the creation of animation based on this general principle of creating frames and specifying
keyframes and frames per second, except that in CSS, the frames comprise HTML elements and the
contents and frame per second (or frame rate) is specified in terms of the amount of time a sequence
should take to complete. The principle endures whether animation is 2D or 3D, both of which can be
created either by CSS by itself or in combination with scripting. The main benefits of CSS animations are
that they make it possible to create basic animations without having to learn to script, and they typically
run more smoothly, even on very slow systems.
18.4.1 @keyframes
The ©keyframes at-rule lets you control the intermediate steps in an animation sequence by specifying the
positions of keyframes (i.e., a list of keyframes) and the properties to be animated. The values it takes
are listed in Table 18.1.
TABLE 18.1
Values Supported by the ©keyframes at-rule
Value Function
<identifier> Specifies a name that identifies an animation sequence (or keyframe list).
from Keyword that specifies to start animation at 0%.
to Keyword that specifies to end animation at 100%.
<percentage> Specifies the point at which keyframes should occur. Value can be between 0% and 100%.
In order for keyframe lists to be valid, they must contain at least 0% (or from) and 100% (or to), as the
two define the animation sequence. Figures 18.3 through 18.5 show examples of how the values are used
with the ©keyframes at-rule, assuming the identifier of the animation to be applied to the selected element
is “shake.” In Figure 18.3, the ©keyframes shake {} rule says to make the background of the element to
which the shake animation is applied red at 0% keyframe, blue at 50% and also scale the size of the
element to 2, and green at 100% as well as scale the element back to its initial size. When a property is
specified at a keyframe but not specified in the succeeding one, the property’s initial value is assumed.
In Figure 18.4, the ©keyframes shake {} rule similarly specifies to make the background of the element
to which the shake animation is applied red at 0% keyframe, blue at 50%, and green at 100%.
In Figure 18.5, the ©keyframes shake {} rule says to make the background of the element to which the
shake animation is applied red at 0% keyframe and green with opacity of 0.5 at 100%.
In the example, the div{} rule styles the content of the <div> element and specifies its animation
properties. The padding property specifies the space between the element’s content and its border and the
font size, text align, and color properties specify text size, its alignment inside the element’s box, and
color, respectively. The animation- name property gives the animation a name (“zooming”), animation-
duration specifies its duration, animation-delay says to wait 1 second after the animation is triggered
before starting it, animation-fill-mode says to display, when animation completes, a combination of the
styles for both first and last executed keyframes, and animation- iteration-count says to play the animation
three times before stopping.
The @keyframes at-rule says to scale the content of the element to which “zooming” animation is
applied to 0.1 at 0% keyframe, scale it to 1.0 and rotate it clockwise by 45% around z-axis at 50%
keyframe, and scale it to 2.0 at 100% keyframe as well as rotate it back to the initial value of 0°, since the
rotateZ() function is not specified at 100% keyframe. To make the element stay at 45°, a separate
transform declaration is required to specify it. Refer to Chapter 11 for more about the transform property.
CHALLENGE 18.1
Rewrite the code in Figure 18.6 using the shorthand animation property and make the text remain at
45% at the end of the animation instead of returning to 0° (i.e., level orientation). Also, make the text
make a full rotation.
In the .ball{} rule in the example, the width and height properties specify the size of the <div> element,
background-color specifies its background color, and border-radius makes it round. The animation
property specifies two animation sequences. For the first, it specifies animation-name as move,
animation- duration as 10 seconds, animation-timing-function as ease-in, animation-iteration-count as
infinite, and animation-direction as alternate. For the second, it specifies animation-name as pulse,
animation- duration as 1 second, animation-timing-function as linear, animation- iteration-count as
infinite, and animation-direction as alternate.
The @keyframes move{} at-rule says to move the element to 0 0 (top-left corner of page) at 0%
keyframe and to 600px 0 (600px horizontally right) at 100%. The @key- frames pulse {} at-rule says to
make the element’s background color orange at 0% keyframe and red at 100%.
CHALLENGE 18.2
Using the same approach as in the example or any other, create a filled circle that changes into a
square as it moves to the right of the screen and back to circle as it moves back.
CHALLENGE 18.3
Implement the example in Figures 18.9 and 18.10, but instead of the box coming from the left, make it
drop down from the top.
18.4.4 CSS Transitions
Transitions in CSS define how a specified value of a property changes to another over time, including the
timing of the change. By default, when change in a property is triggered, it happens instantly. With
transition, the behavior of this change can be controlled. A change is triggered in various ways, such as by
a page loading, using pseudo-classes (e.g., :hover and :active), and scripting. The properties used to
create transition are transition-delay, transition-duration, transition-property, and transition-timing-
function. Table 18.3 lists their functions.
The shorthand transition property can be used to specify the properties in the table and for multiple
property names. There is no strict order in which the properties must be specified, except that the value
for the transition-duration property must come before and that of transition-delay. Typically, the transition-
property value will be first. Figures 18.11 and 18.12 show an example in which multiple transitions are
applied to an element.
TABLE 18.3
Transition Properties
Property Function
transition- Specifies the names of properties to which to apply a transition effect. It is non-inherited and the values taken are none (which
property means no transition), all (which means to apply transition to all properties that support it) and IDENT (which is the name of the
property to which transition should apply, such as margin-left).
transition- Specifies the amount of time to wait between when a change to a property is triggered and the time the change starts. It is non-
delay inherited and specified in seconds (s) or milliseconds (ms). Multiple values can be specified, in which case, they are comma-
separated and each value is applied to the corresponding property on the list specified by the transition-property.
transition- Specifies the number of seconds (s) or milliseconds (ms) a transition takes to complete. It is non-inherited and its default value is 0s,
duration which produces no transition. When multiple values are specified (which must be comma separated), each value is applied to the
corresponding property on the list specified by the transition-property.
transition- Specifies the behavior of a transition over time. In essence, it controls speed variation over time. It is non-inherited and the value it
timing- takes is a CSS a timing-function value that is specified in keywords, which are linear, ease-in, ease-in-out, ease-out, step-start, and
function step-end, or function values: cubic-bezier() and steps(). The cubic-bezier() function takes four values (x1, y1, x2, y2) that define the
curve for the animation to follow. Values x1 and x2 must be between 0 and 1. Example: cubic-bezier(0.1, 0.6, 1.0, 0.2). The step()
function takes one or two values that specify intervals. The first is the number of steps and the second direction, which can be start
or end. Example: step(4, start). If the second value is missing, end is assumed.
The div{} rule in the example specifies the initial width, height, and background-color of the <div>
element. The transition property specifies two transitions. For the first, it specifies transition-property as
width, transition-duration as 0.5 seconds, and transition-timing-function as ease-out. For the second, it
specifies transition-property as height, transition-duration as 0.5 seconds, and transition-timing-function
as ease-out. Notice that the sets of transition values are comma separated. The div:hover{} rule specifies
the width and height to transition into when the cursor hovers over the element. Also, the cursor property
says to change the cursor shape to a pointer.
FIGURE 18.11 Using the transition property.
CHALLENGE 18.4
Modify the code in Figure 18.11, combining transition with the transform property, so that the square
rotates and changes color as it gets bigger.
CHALLENGE 18.5
Rewrite the example in Figure 18.11, using the transform property with the scale(0) function, so that
when the cursor hovers over the square, it instantly becomes bigger.
CHALLENGE 18.6
Also using the transform property with the scale(0) function, implement a 3-image gallery with
thumbnails, so that each thumbnail is a hyperlink to a larger version of the thumbnail and when the
cursor hovers over it, it instantly becomes bigger. Hint: Use <img> element to add the images
(Chapter 6) and <a> element to add hyperlink (Chapter 4).
18.5 3D Animation
3D animation can probably be best simplistically described as adding a third dimension (i.e., depth) to
the movement of a 2D or 3D object. Movement can be along x-, y-, or z-axis and around these axes. This
means 3D animation has what is described as six degrees of freedom, which is the ability to move
forward/backward, up/down, left/ right (i.e., along x-, y-, z-axis), plus yaw, pitch, and roll, as illustrated
in Figure 18.13. The terms “yaw,” “pitch,” and “roll” essentially define the orientation of an object within
a 3D space.
Yaw is rotation around y-axis (i.e., left-right orientation). An example is when the head is being
turned left or right.
Pitch is rotation around x-axis (i.e., up or down orientation). An example is when the head is
being nodded or thrown back.
Roll is rotation around z-axis (i.e., side to side). An example is when the head is being cocked
left or right.
The #banner{} rule styles the <div> element of id=“banner”. The width and height properties set the
size, margin centers it horizontally inside the parent <div> element (i.e., id=“container”), background-
color sets the background color, border sets the border to black 2px-thick solid line, and border-radius
makes the corners round. For the animation, the animation-name specifies the name of the animation as
“rotation,” animation-timing-function specifies linear motion, animation-duration sets the length of the
animation sequence to 6 seconds, and animation-iteration-count says to play the animation indefinitely.
The p{} rule styles the text in the <p> element. The font property makes the text bold, 32px in size, and
Arial, text-align centers it horizontally, and margin centers it vertically. The @keyframes rotation{} at-
rule creates the “rotation” animation and says to rotate the element to which the rotation animation applies
around the y-axis to 0° at 0% keyframe and 360° at 100%.
CHALLENGE 18.7
Implement the example and modify it to make the banner rotate in the opposite direction and also
make it stop when the cursor is over it. Lastly, experiment with the value of the animation-timing-
function property and also make the back-face of the banner invisible to see the effect. Refer to
Chapter 11 on how to make an element’s back-face invisible.
The #imagel{}, #image2{}, #image3{}, #image4{}, and #image5{} rules each rotates the
corresponding <img> element around y-axis and moves it right along the x-axis to a new position as well
as gives it left padding so that the contained image is at the right end of the element’s box. The angles by
which the elements are rotated from their initial orientation are multiple of 72 (which is derived from
dividing 360° by the total numbers of images). Note that rotation must be specified before translation,
because doing it the other way round will give a different result.
In the #wrapper{} rule, the perspective property gives perspective to the child elements of the <div>
element of id=“wrapper”, padding extends the left edges of the <img> elements by the same amount so
that they meet at the central axis, and height produces the indirect effect of tilting the carousel up. The
higher the value, the more the carousel is tilted up.
The #carousel{} rule sets the animation properties for the <div> element of id=“carousel . The
animation-name property specifies the name (“carousel”), animation-duration sets duration of animation
to 7 seconds, animationtiming-function sets motion type to linear, transform-style says to display the child
elements of the element in 3D space, and transform-origin specifies the x-y-z coordinates of the point of
rotation for the element, which is where the <img> elements meet. The @keyframes carousel{} at-rule
creates the carousel animation and says to rotate the element to which carousel animation applies 0°
around y-axis at 0% keyframe and -360° at 100%.
CHALLENGE 18.8
Implement the example in Figures 18.17 and 18.18 with your own images and experiment with the
values of the transform and padding properties.
CHALLENGE 18.9
Modify the example so that when the cursor is over any of the images, the carousel stops and the
cursor shape changes to a pointer. Also, when an image is clicked, link the user to another page or
site. Hint: Try using the :hover pseudo-class (Chapter 8), the animation-play-state property, and the
<a> element (Chapters 4 and 6).
Feedback in hover effect can also be in the form of presenting a brief description of an element’s
function or state. For example, placing the cursor over the icon for setting the viewing parameters for a
YouTube video says “Settings.” Typically, the animation used in hover effect is noncontinuous and fit for
purpose. However, in some cases, it may be more useful to have continuous animation that better
describes a function, particularly when icons project ambiguous messages about their functions. For
example, when the cursor goes over a print-function icon, the icon can change state to one of continuous
animation, in which paper seems to come out of a printer, rather than the icon or its border just changing
color.
19.1 Introduction
In CSS, the layout of Web pages used to be achieved through the use of various sizing and positioning of
CSS properties that were not designed specifically for the purpose. This made the creation of layouts
cumbersome and the results unpredictable on screens of different sizes. The introduction of the CSS
flexible box and grid layout models is designed to address this problem. These models enable you to
specify how a container element should control the behavior of the elements inside it, making the creation
of layouts more straightforward and more intuitive. This chapter introduces the flexible box layout model,
and Chapter 20 deals with grid layout.
Flex items are laid out along the main axis in the container starting at the main- start edge and going
toward the main-end edge. The main axis goes in the same direction as the inline axis, which is
horizontal or vertical, depending on writing mode, and represents the direction in which inline-level
content flows. A line of flex items is contained in what is known as a flex line. Flex lines are laid out
along the cross axis in the container, starting at the cross-start edge and going toward the cross-end edge.
The cross axis essentially goes in the same direction as the block axis (which is vertical or horizontal,
depending on writing mode) and represents the direction in which block-level content flows. The
directions of the main axis (i.e., main dimension) and that of the cross axis (i.e., cross dimension) go in
the same ways as the current writing mode and determine whether an edge is the main-start, main-end,
cross-start, or cross-end edge. Also, whether main size or cross size represents the width or height of an
item depends on these dimensions. This is because the flexbox layout model is used to represent multiple
directions of content flow, such as left to right, right to left, and top to bottom.
A flex container can be single-line or multi-line, depending whether or not lines are wrapped. It is
single-line if it has only one line of flex items that is not broken, even if the line overflows the container’s
edge. It is multi-line if the lines of items are broken into multiple lines, the same way that text is wrapped
onto multiple lines in a document. With the flexbox properties, it is possible to achieve many layout goals
easily, such as:
Center an element inside a page.
Make elements or containers flow horizontally or vertically in any order.
Create a row of elements, such as buttons, that collapses vertically on smaller screens.
A flex container can be defined as a block-level or an inline-level container and created by assigning
flex or inline-flex value to the display property (discussed in ), respectively. For example, the display:
flex; declaration says to make the element to which it is applied a block-level flex container and display:
inline-flex; says to make it an inline-level flex container. Once created, elements inside a flex container
automatically become flex items and are laid out along the direction of the main axis or the cross axis.
Some flexbox properties apply only to the flex container and affect all the items inside it, while others
apply only to individual flex items.
NOTE: Flexbox properties and other CSS properties
Some properties have no effect on the behavior of flex items, such as column, float, and clear
properties (presented in Chapter 12) and vertical-align (introduced in Chapter 14).
19.4 Controlling Flow Direction of Flex Items
The flow direction of flex items describes the direction in which flex items are laid out within the
containing flex container. The direction can be from left to right, right to left, top to bottom, or bottom to
top. These directions can also be described in terms of where flow starts and ends, and how this is
interpreted depends on the current writing mode, such as left-to-right-top-to-bottom. The property used to
control this direction is the flex-direction property. It is specified in the rule for the flex container (since it
applies to all its flex items) and sets the direction in which the flex items are laid out in the container. It is
non-inherited and takes the values listed in Table 19.1. Figure 19.2 shows the effects of the values, and
Figures 19.3 and 19.4 show example usage, using the row-reverse value.
In the #container{} rule in the example, the width and height properties specify the size of the <div>
element of id=“container”, border makes its border 1px-thick black solid line, display makes it a block-
level flex container, and flex- direction specifies to lay out the flex items (i.e., the <div> elements inside
it) in reverse direction. The #container div{} rule styles the <div> elements (i.e., flex items) inside the
flex container, specifying the size, background color, the thickness, line- style, and color of the border,
and the border radius (i.e., the roundness of the corners).
TABLE 19.1
Values Supported by the flex-direction Property
Value Function
row Lays out items in the direction of the inline axis of the current writing mode, for example, left to right. It is the default.
row-reverse Lays out items in the opposite direction to the inline axis in the current writing mode.
column Lays out items in the direction of the block axis of the current writing mode. For example, this is vertical in horizontal writing
mode.
column- Lays out items in the opposite direction to the block axis in the current writing mode.
reverse
CHALLENGE 19.1
Implement the example in Figures 19.3 and 19.4, using each of the four values in Table 19.1 to see
their effect. Also, vary both the size of the flex container and the flex items to better understand the
behavior of the items.
In the #container{} rule in the example, the width and height properties specify the size of the <div>
element of id=“container”, the border property makes the border 1px-thick black solid line, display
makes the element a flex container, and flex- wrap says to wrap the <div> elements (i.e., flex items)
inside it to the next line when necessary. The #container div{} rule styles the <div> elements (i.e., flex
items) inside the flex container, specifying the size, background color, the thickness, style and color of the
border, and the roundness of the corners.
CHALLENGE 19.2
Implement the example in Figures 19.6 and 19.7, using each of the three values in Table 19.2 to see
their effect. Also, vary both the size of the flex container and the flex items to better understand the
behavior of the items.
CHALLENGE 19.3
Rewrite flex-flow: row-reverse wrap in longhand and explain what the declaration does.
CHALLENGE 19.4
Modify the code in Figures 19.6 and 19.7 accordingly, using the flex-flow property to lay out the flex
items vertically and make them wrap at the top or bottom.
CHALLENGE 19.5
Create a <div> flex container of id=“container” and six <div> flex item inside it of id equal to
“one,” “two,” “three,” “four,” “five,” and “six,” then use the CSS rules below to study how the flex-
grow, flex-shrink, and flex- basis properties work, alternating between the properties and varying
their values.
#container { width: 300px; height: 200px; border: 1px solid grey; display: flex;
}
#container div { height: 45px; background-color: orange; border: 1px solid black; flex-basis: 30px;
}
#container #three { flex-basis: 70px; }
19.7.2 Specifying All Flex Items Sizing Factors with One Property
The property for specifying flex-grow, flex-shrink, and flex-basis longhand properties together is the flex
shorthand property. When used to specify the properties, values are specified in the order flex-grow, flex-
shrink, and flex- basis (e.g., flex: 3 2 15%), but only flex-grow is mandatory. The property can also take
none or auto keyword. When flex-grow is omitted, it is set to 1; when flex-shrink is omitted, it is set to 1;
and when flex-basis is omitted, it is set to 0. Table 19.4 shows examples of the common ways values are
specified and Figure 19.8 shows how the property is used.
In the .flex-container {} rule in the example, the display property makes the <div> element of
class=“flex-container” a flex container and the border property makes its border 2px-thick black solid
line. The .flex-container div{} rule styles the <div> elements (i.e., the flex items) inside the flex
container, giving them background color, padding to make them bigger, 2px-thick grey border, and
horizontally center-aligning their contents. The .one{} and .two{} rules each specifies the flex-grow, flex-
shrink, and flex-basis properties. These three properties work together to specify that the <div> element
of class=“two” (i.e., item 2) should take five times more space than the <div> element of class=“one”
(i.e., item 1) when there is enough space, and take three times less space when there is not enough space.
TABLE 19.4
Commonly Used Values for the flex Property
FIGURE 19.8 Example usage of the flex property.
CHALLENGE 19.6
Again, the best way to understand how the flex property works is to see its effect in use. Implement
the code in Figure 19.8, adjusting the flex values and the width of the browser to vary the amount of
available space to see the different results produced.
In the .container{} rule in the example, the width and height properties specify the size of the
<div> element of class=“container”, the display property makes the element a block-level flex
container, and flex-flow specifies to flow the children (flex items) vertically. In the .header,
.footer{} rule, the height property specifies the height for the <div> element of class=“header” and
<div> element of class=“footer”, background-color makes their background color grey, text-align
centers their text contents, and flex makes their size inflexible. In the .content{} rule, the background-
color property makes the background color of the <div> element of class=“content” orange, text-
align centers its content, and flex makes the size fully flexible, making it fill the space in the flex
container not taken by other items.
CHALLENGE 19.7
Implement the example in Figure 19.9 and vary the values for the flex property in the .header,
.footer{}, and .content{} rules to see their effects on the layout. Also, remove the height property
from the .header, .footer{} rule and explain the resulting change in the header and the footer.
19.8.1.1 justify-content
The justify-content property aligns flex items along the main axis of the current flex line (e.g., along the
horizontal axis in a horizontal writing mode), using the space available after the space needed for flexible
lengths and auto margins (margins with auto value) has been allocated. It basically controls how leftover
space is distributed between flex items along the main axis. This means that if even one flex item has an
indefinite need for space (e.g., flex-grow value that is greater than 0), the property will have no effect,
because the item will take up all extra space and there will be no leftover. It is non-inherited and the
values it supports are listed in Table 19.5. Figure 19.11 illustrates the effects of the values and Figure
19.12 shows example usage of the property.
TABLE 19.5
Values for the justify-content Property
Value Function
flex-start Makes flex items start from the main-start, with the margin of the first item flush with the main- start and each succeeding item
flush with the end of the preceding one. It is the default.
flex-end Makes items start from the main-end, with the margin edge of the item flush with the main-end and each preceding item flush with
the succeeding one.
center Places items at the center of the line, with each flush with the next and the space between the first item and the main-start and the
last item and the main-end equal.
space- Spreads items evenly over a line, with the first item flush with main-start and the last item with the main-end.
between
space- Surrounds each item with equal space. This means that the spaces between adjacent items are equal and twice that between the
around first item and the main-start and the last item and the main-end.
FIGURE 19.11 Effects of justify-content values.
In the #flex-container{} rule in the example, the border property makes the border of the <div> element
of id=“flex-container” 1px-thick black solid line, the display property makes the element a flex container,
and justify- content says to lay out the elements (flex items) in the container according to the rules of the
flex-start value described in Table 19.5. The #flex-container div{} rule styles the <div> elements (flex
items) inside the flex container, specifying the size, background color, and the thickness, style, and color
of the border.
CHALLENGE 19.8
Implement the example in Figure 19.12 and try out, in the #flex-container {} rule, the other values
listed in Table 19.5 for the justify-content property. Also, apply flex-grow that is greater than 0 to
any of the elements and explain what happens. Also, apply the property to all the elements and see
the effect.
CHALLENGE 19.9
To better understand the behavior of the flex items, place a sizeable amount of text in them in the
example you have just implemented. Also experiment with different values of width and height, and
with no values specified while also varying the width of the browser window. Given your
observation, how does using justify-content compare with using the multi-column layout properties
(discussed in Chapter 12)? Is one better suited for some design requirements than the other, and
which sort of requirements?
19.8.1.2 align-content
The align-content property aligns flex lines in a multi-line flex container when there is enough space in the
cross axis (e.g., enough vertical space in horizontal writing mode). It does this in a similar way that the
justify-content does it along the main axis. The property has no effect on a single-line container. This
means that flex line must be longer than the flex container (and the flex-wrap property used to wrap the
line) in order for the property to have an effect. It is non-inherited and the values supported are listed in
Table 19.6. Figure 19.13 shows their effects.
Figure 19.14 shows an example of how the align-content property is used. In the #flex-container{} rule,
the width and height properties specify the size of the <div> element of id=“container”, the border
property makes its border 1px-thick black solid line, display makes it a flex container, flex-wrap says to
wrap lines of items to the next line when necessary, and align-content says to align lines of items
according to the rules of the flex-start value, as described in Table 19.6. The #container div{} rule styles
the <div> elements (i.e., flex items) inside the flex container, specifying the size, background color, the
thickness, style, and color of the border, and the roundness of the elements’ corners.
TABLE 19.6
Values for the align-content Property
FIGURE 19.13 Effects of the values of align-content property.
CHALLENGE 19.10
To better understand the effects of the values of the align-content property, implement the example in
Figure 19.14 and try out the other values in Table 19.6. Also, remove the flex-wrap declaration to
see the effect.
19.8.1.3 align-items
The align-items property aligns all items in a flex container in the cross axis of the current line of the
container. This means, for example, that if the main axis is in the horizontal direction, items are vertically
aligned. The property is non-inherited and Table 19.7 lists the values it supports. Figure 19.15 shows the
effects of the values, and Figures 19.16 and 19.17 show an example of how it is used.
TABLE 19.7
Values for the align-items Property
Value Function
flex- Places the cross-start margin-edge of items flush with the cross-start edge of the current flex line.
start
flex- Places the cross-end margin-edge of items flush with the cross-end edge of the current flex line.
end
center Centers an item in the cross axis within the current flex line. If the cross size (i.e., width/height) of the item is greater than that of the
flex line, the item overflows equally in both directions.
stretch Stretches items to fill the cross size (i.e., width/height) of the current flex line, while respecting any specified min-width, min-height,
max-width, or max-height. It is the default.
baseline Aligns the baselines of items. Produces the same result as flex-start (as shown in Figure 19.15), if the baselines of items are the
same; otherwise the item with the largest distance between its baseline and its cross-start margin edge is the one that will have its
cross-start edge flush with the cross-start edge of the current flex line. The baseline of an item is typically the baseline of the biggest
text in its first line of text. This is explained further with the example in Figure 19.16 and the subsequent CHALLENGE box.
In the example, the #container{} rule specifies the size of the <div> element of id=“container”, styles
its border (making it 1px-thick black solid line), makes the element a flex container, and says to place the
flex items vertically in the center of the container. The #container div{} rule specifies the width of the
<div> elements (i.e., flex items) inside the <div> element of id=“container” (i.e., flex container) and also
styles their borders. The #container .one{}, #container.two{}, #container .three{}, and #container.four{}
rules specify the background color and padding for each of the flex items. Notice that the content of the
first and last flex items is a space ( ). This is to give them height because without content, a box
collapses into a line.
CHALLENGE 19.11
Using your own content, implement the example in Figure 19.16 (filling all the flex items with text),
and try out the other values listed in Table 19.7. Also, to better understand the effect of the baseline
value, increase the size of the first line of text in one of the elements to see how this affects the
alignment of the top edges of the flex items against the top edge of the flex container.
CHALLENGE 19.12
Again, implement the example in Figure 19.16 but without content in items one and four, and also
modify it so that all the flex items are horizontally centered in the flex container and flex items two
and three are of the same size and contain an image each. Also, make the images links to other
websites.
CHALLENGE 19.13
The example in Chapter 14, Section 14.3.3, in which content was both horizontally and vertically
centered, can be achieved using the justify-content and align-items properties together. See if you can
implement it.
CHALLENGE 19.14
Implement the example in Figure 19.18 and experiment with the values of the flex properties. Also,
create a full page design, using the idea in the example. For example, place headings in the items,
center the flex container, and so on.
CHALLENGE 19.15
Modify the example so that the <nav> element is part of the header and the <aside> element is before
the <article> element in the flex container. Also, center the contents of all elements.
CHALLENGE 19.16
The following layouts can be created using the flexbox properties discussed so far, and others like
margin and padding. See if you can produce them.
20.1 Introduction
As mentioned in Chapter 19, layout was achieved in the past in CSS through the use of various sizing and
positioning CSS properties that were not specifically intended for the purpose, making the creation of
layouts cumbersome and their delivery unpredictable on screens of different sizes. The CSS flexible box
layout model, which is one of the solutions to the problem, was fully introduced in Chapter 19. In this
chapter, the grid layout model has been discussed. Like with the flexible box model, this model enables
you to specify how a container element should control the behavior of the elements inside it, making it
possible to create complex layouts easily. While most browsers are yet to fully implement the model as of
time of writing, they are likely to soon, as it is designed to represent one of the ways forward for creating
layouts in Web design.
In Firefox, type about:config in the address bar and navigate to and enable the
“layout.css.grid.enabled” flag.
In Chrome, type chrome://flags in the address bar and navigate to and enable the “experimental
web platform features” flag.
In Opera, type opera://flags in the address bar and navigate to and enable the “experimental
web platform features” flag.
Also, some of the things introduced here may change by the time the specification is finalized, but the
changes should be minimal.
In the example, the .grid{} rule styles the <div> element of class=“grid”. The width property makes its
width 90% of that of the browser window and height specifies its height. The display property makes it a
grid container and its children automatically grid items. The grid-template-columns property specifies
“first” as the name for the first column grid line, a size of 160px for the first column, “second” as the
name for the second column grid line, a size of 1fr (i.e., all free space) for the second column, and “last”
as the name for the last column grid line. The grid-template-rows property specifies the rows in a similar
manner. Given the specified columns and rows, the browser uses the auto-placement algorithm to
automatically place the defined grid items (i.e., <div> elements of class equal to “A,” “B,” “C,” “D,”
“E,” or “F”) in the defined grid areas. This is how the grid items are positioned as shown in Figure 20.4
without any explicit instructions given on where to place them. Notice also that the grid items are by
default stretched to fit the grid areas. The .A{}, .B{}, .C{}, .D{}, .E{}, and .F{} rules specify the background
color for the respective grid item.
CHALLENGE 20.1
Rewrite the following in full:
grid-template-columns: repeat(4, [column] 100px); grid-template-rows: repeat(3, [row] auto);
Also, what does not make much sense about the grid produced?
CHALLENGE 20.2
Implement the example in Figure 20.3, but specify the size of the left column with the “fr” unit, using
a value that produces the same result. How does this practically compare with specifying the value
in absolute units in relation to screens of different sizes?
CHALLENGE 20.3
To the example in Figure 20.3, add an extra grid item and style it to make it visible, but without
creating a grid area for it. Then explain what happens.
CHALLENGE 20.4
In the example in Figure 20.3, replace the track sizes with the auto keyword to see how the value
sizes to content.
20.5.1.4 grid-template-areas
The grid-template-areas property provides another method of defining a grid. It is used to specify named
grid areas that are not related to any specific grid item but can be referenced by grid properties used to
specify the placement of grid items (i.e., where grid items start and end, and how many columns or rows
to span). The property is noninherited and takes one of two values: none (which defines no grid areas) or
strings of grid names. Each string represents a row, and each name in the string a column. It is essentially
like using the names to construct a grid. As well as a name, one or more full stops can be used to
represent a null (empty) cell. All cells together must form a rectangle for a grid definition to be valid.
Figure 20.5 shows how the property is used and Figure 20.6 the result.
In the #grid{} rule in the example, width makes the width of the element of id=“grid” 90% that of the
browser window, height specifies its height, and display makes it a grid container. The grid-template-
areas property specifies three strings with two names in each. This means that three rows and two
columns are defined for the grid template. This also means that the grid has six (i.e., 3 x 2) cells. Adjacent
cells that have the same name are merged and treated as one cell. When a grid item is used in the same
row or column more than once, it must be used consecutively. The grid-template-rows property specifies
the size of the three rows and grid-template-rows specifies the size of the two columns. In the #grid
header{} rule, grid-area assigns the <header> element (a grid item) to each grid area named “header” and
background-color specifies the color. The #grid nav{}, #grid main{}, and #grid footer{} rules perform a
similar function for <nav>, <main>, and <footer> elements, respectively. The grid-area property is
shorthand for specifying the start and end of columns and rows (discussed further later).
CHALLENGE 20.5
Modify the code in Figure 20.5 to include another 150px sidebar on the right.
CHALLENGE 20.6
Again, implement the code in Figure 20.5, but with “...” in place of the grid area named “main” to
see the effect.
CHALLENGE 20.7
Which of these grid definitions do not form a rectangle and what does this mean?
20.5.1.5 grid-template
The grid-template property is the shorthand for grid-template-columns, grid-template-rows, and grid-
template-areas, and allows you to specify columns, rows, and areas together. It is non-inherited and takes
the values listed in Table 20.2.
TABLE 20.2
Values and Value Formats Used with grid-template
Value/Value Form Function
none Sets grid-template-columns, grid-template-rows, and grid-template-areas to none.
subgrid Sets the value of grid-template-columns and grid-template-rows to subgrid, and that of grid-template-areas to none.
<grid-template- Sets grid-template-columns and grid-template-rows to the specified values and the value of grid-template-areas to none.
columns> / < grid- For example:
template-rows> grid-template: 160px 1fr / 60px 1fr 60px;
...is the same as:
grid-template-columns: 160px 1fr;
grid-template-rows: 60px 1fr 60px;
grid-template-areas: none;
...which produces the same layout as Figure 20.4.
<track-list> / Sets grid-template-columns to the values specified in <track-list>; sets grid-template-rows to the values in <line-names>
<line-names> and <track-size>, using those in <line-names> for grid-line names and those in <track-size> for track sizes; sets grid-
<string> template-areas to the values in <strings>. For example:
<track-size> grid-template: 150px 1fr /
<line-names> [header-top] “header header” 50px [header-bottom]
[main-top] “nav main” 1fr [main-bottom]
[footer-top] “footer footer” 50px [footer-bottom];
...is the same as:
grid-template-areas:
“header header””nav main”
“footer footer”;
grid-template-columns: 150px 1fr;
grid-template-rows: [header-top] 50px
[header-bottom main-top] 1fr
[main-bottom footer-top] 50px [footer-bottom];
...which produces the same result as Figure 20.5.
CHALLENGE 20.8
Rewrite the following rule using only the grid-template property:
grid-template-areas: “header header header”
“nav main ads”
“footer footer footer”;
grid-template-columns: 160px 1fr 160px; grid-template-rows: [header-start] 50px [header-end main-
start] 1fr
[main-end footer-start] 50px [footer-end];
In the #grid{} rule in the example, display makes the <div> element of id= “grid” a grid container and
its six children (i.e., <div> elements of id equal to “A,” “B,” “C,” “D,” “E,” and “F”) grid items,
automatically. The grid-template-columns and grid-template-rows define a column and a row of 100px
each, creating a grid that has only one cell and space for only one grid item. This means that given rule
#A{}, which explicitly places grid item “A” in the explicitly specified column and row (using grid-
column and grid-row), and rules #B{}, #C{}, #D{}, #E{}, and #F{}, which similarly explicitly place grid
items “B” to “F” in the grid but in columns and rows that are not explicitly specified, the grid container
automatically creates five implicit columns and rows to hold grid items “B” to “F” and sizes them to the
width or height of the adjacent column or row. Notice their sizes in the output on the left in Figure 20.8
and the result on the right when the grid-auto-columns and grid-auto-rows properties are used to set their
sizes to 100px. The rest of the declarations in rules #A{ }, #B{}, #C{}, #D{}, #E{}, and #F{} simply specify
the grid items’ background color. Note that the grid-column and grid-row properties are used here only to
more clearly demonstrate the functions of grid-auto-columns and grid-auto-rows, and discussed in greater
detail later in this chapter with other properties used for positioning grid items in the grid.
CHALLENGE 20.9
Implement Figure 20.7 and experiment with different values for the grid-autocolumns and grid-auto-
rows properties to see possible applications to page layout.
CHALLENGE 20.10
Again, implement Figure 20.7, but first without explicitly positioning any of the grid items, then
without this or sizing the implicit grid columns or rows. Then explain the results in terms of how grid
items are automatically placed in the grid as well as in relation to the order of the items in the HTML
source.
20.5.2.2 grid-auto-flow
The grid-auto-flow property allows you to specify how the auto-placement algorithm should handle the
flow of grid items that are not explicitly positioned if there are cells to contain them. It is non-inherited
and supports the values listed in Table 20.3. Figure 20.9 shows how the property is used, and Figure
20.10 shows the effects of using different values with it.
TABLE 20.3
The Values Used for grid-auto-flow
Value Function
row A keyword that specifies that the flow direction of items’ placement should be row by row (i.e., starting from the first column, one row
is filled first, then the next, and so on).
column A keyword that specifies that the flow direction of items’ placement should be column by column (i.e., starting from the first row, one
column is filled first, then the next, and so on).
dense A keyword that represents a mode that packs the grid densely by filling in earlier holes in the grid with subsequent smaller items that
fit. Using it means that items may end up appearing out of order. When not specified, the sparse mode, which is the default, is used.
Because this value is a mode rather than flow direction, it can be combined with row or column, such as, thus, row dense; and column
dense;.
In the .grid{} rule in the example, display makes the element of class=“grid” a grid container and its
children grid items, grid-template-columns specifies five columns and grid-template-rows three rows.
The grid-auto-flow property specifies how the grid items whose positions are not explicitly specified
should be positioned in the grid. In order to be able to demonstrate the effects of all the values for the
property, the grid-column and grid-row properties are again used here, but discussed in greater detail
shortly. They are used to explicitly specify the column-row positions and spans for grid items “A” and
“B,” and the positioning is such that a preceding cell is left empty so that the dense value can have an
effect. Basically, “A” occupies column 2 row 1 and spans two rows, and “B” occupies the next column
and row 1, and spans two columns. Notice in the outputs for the row and column values that the first grid
cell (i.e., column 1, row 1) is empty and that it is filled with an item when the dense value is used and that
this affects the ordering of the items. Notice also how the position of item A is always maintained because
it is explicitly specified.
CHALLENGE 20.11
Implement the example but with the position of grid item “B” also explicitly specified to see how
this changes the behavior of the layout with different values.
CHALLENGE 20.12
Implement the example in Figure 20.11 and experiment with large gutters. Can you see possible
design applications?
CHALLENGE 20.13
Should the sizes of gutters be specified in relative or absolute units? Give reasons for your answer?
Hint: Think, for example, of implications in screens of different sizes.
CHALLENGE 20.14
Rewrite the following using only the grid property:
grid-template-columns: 1fr 2fr 1fr;
grid-template-rows: 60px 1fr 60px;
20.5.5 Specifying Grid Item Placement within the Grid
As earlier examples have repeatedly shown, it is possible to explicitly specify the position and span of a
grid item in the grid. The properties used to achieve this are known as grid-placement properties and
allow you to arrange and order grid items freely within the grid, irrespective of how the grid items are
ordered in the source code. Placement is described in terms of the grid item’s edge that comes first in the
block-flow direction (i.e., block-start), the grid item’s edge at the end of block-flow direction (i.e.,
block-end), the grid item’s edge from which the content of a grid item starts (i.e., inline-start), and the
grid item’s edge at which the content of an item ends (i.e., inline-end). Which edge is which depends on
the writing mode. For example, in the left-to-right-top-to-bottom writing mode, block-start is top, block-
end is bottom, inline-start is left, and inline-end is right. The grid placement properties are grid-column-
start, grid-row-start, grid-column-end, grid-row-end, grid-column, grid-row, and grid-area. Figure 20.13
shows the longhand- shorthand relationship between them.
The example is again quite basic for the purpose of explanation. In the .grid{} rule, display defines a
grid container (which automatically makes its children grid items), width specifies its width, height
specifies the height, grid-template-columns specifies four columns and their start and end grid line names,
and grid-template-rows specifies two rows in the same way, creating a total of eight grid areas (or cells).
Grid items “A,” “C,” “D,” and “E” are placed automatically by the placement algorithm and rules. A{},
.C{}, .D{}, and. E{} specify their background color. Only grid item “B” is explicitly positioned. The .B{}
rule specifies its background color as well as its explicit placement thus: grid-column-start says the start
position within the grid row should be grid line 2 and grid-column-end says the end position should span
two grid lines (which extends the item to the “fourth” line). Similarly, grid-row-start says that the start
position within the grid column should be the grid line named “first” and grid-row-end says that the end
position should span grid lines up to the one named “last.”
CHALLENGE 20.15
What do the following declarations say?
grid-column-start: -4; grid-column-end: span 2;
CHALLENGE 20.16
Modify the code in Figure 20.15 to create the layout below:
CHALLENGE 20.17
As you might have already gathered, it is possible to use most of the CSS properties introduced so
far to style grids and grid items. Again, modify the code in Figure 20.15 to create the layout below,
using the appropriate properties to rotate the grid items as shown. (Hint: See Chapter 11)
The grid-column and grid-row properties in the example specify the same values specified earlier in
Figure 20.15 with corresponding longhand properties thus: grid-column sets grid-column-start to “2” and
grid-column-end to “span 2,” and grid-row sets grid-row-start to “first” and grid-row-end to “span last.”
CHALLENGE 20.18
Using the HTML code in Figure 20.14, modify the values of the grid-column and grid-row properties
in the . B{ } rule in Figure 20.17 to achieve the structure below:
20.5.5.3.1 grid-area
The grid-area property is a shorter shorthand property for grid-column-start, grid-column-end, grid-row-
start, and grid-row-end that allows you to specify the values for these longhand properties in a single
declaration in the order <grid-row-start>/<grid-column-start>/<grid-row-end>/<grid-column-end>,
slashes included. Like the longhand properties, it allows you to specify the position and size of a grid
item within the grid. It is non-inherited and supports the same types of values listed earlier in Table 20.5
for its longhand properties. The property can be used to specify single or multiple values as well as
combinations of values. Table 20.6 lists some of them and how they are interpreted. Figure 20.18 shows
how the property can be used to achieve, again, the same result as in Figure 20.16.
TABLE 20.6
Values Combinations for grid-area and Their Interpretation
Values Combination Meaning
When four values are grid-row-start is set to the first, grid-column-start to the second, grid-row-end to the third, and grid-column-end
specified to the fourth.
When grid-column-end is grid-column-end is set to the value of grid-column-start or auto.
omitted
When grid-row-end is omitted grid-row-end is set to the value of grid-row-start or auto.
When grid-column-start is All four longhand properties are set to the value of grid-row-start or auto.
omitted
In the example, the grid-area property specifies the same values specified with the longhand properties
in Figure 20.15. It sets grid-row-start to “first”, grid-column-start to “2”, grid-row-end to “span last”, and
grid-column-end to “span 2.”
CHALLENGE 20.19
Using the HTML code in Figure 20.14 and modify the values of the grid-area property in the . B{ }
rule in Figure 20.18 to achieve the structure below:
20.6 Aligning Grid and Grid Items
The alignment of grid and grid items can also be controlled, and this is achieved using the box-alignment
properties, some of which have been introduced previously in Chapter 19. These properties allow you to
control the alignment of boxes inside boxes. Essentially, they align contents within element, element
within its parent, and items inside element; and alignment can be along inline/row and cross/column axes.
The properties are justify-content, align-content, justify-self, align-self, justify-items, and align-items, and
they take the same set of value keywords that specify the position of what is being aligned (known as
alignment subject) relative to its containing box (known as alignment container). Table 20.7 lists the
set of values supported in grid layout. Note that the values with “self-” prefix apply only to properties
with “-self” suffix.
TABLE 20.7
Values Used with Box-Alignment Properties in Grid Layout
20.6.1 Aligning All Grid Items in a Grid Container
The properties used to align all grid items collectively inside a grid container are justify-content and
align-content, and justify-items and align-items, and they are specified inside the grid container’s rule.
In the example, the declarations in the .grid{} rule are again the same as in previous examples, except
for a few differences. The rule makes the element of class=“grid” a grid container and its children grid
items, sets its width and height, sets three columns and two rows, sets border line-style, and centers the
grid (and grid items) in the grid container along both row and column axes. Notice that the justify-content
and align-content properties are applied on the grid container and not on the individual grid items. This is
because it is the container that is aligning the items rather than the items aligning themselves within the
container. Also, as in previous examples, the .A{}, .B{}, .C{}, .D{}, .E{}, and. F{} rules simply specify the
background color for the items.
CHALLENGE 20.20
If you use the start value with the justify-content property in the example, you will get the same result
as using the left value. Why is having the two values not redundant?
CHALLENGE 20.21
A possible useful application of the layout in the example is a media gallery in which thumbnails
(reduced versions of media) are displayed for users to click and be taken to the actual media objects.
Implement the example, replacing the contents of the grid items with clickable image thumbnails,
which when clicked take users to the actual images. You can use placeholder images from sites like
http://lorempixel.com. Hint: See Chapter 6 for how to create clickable images.
In the example, the .grid{} rule again does something similar to the previous example. It makes the
element of class = “grid” a grid container and its children grid items, sets its width and height, sets two
columns and two rows, makes its border 1px solid black line, and aligns the contained grid items. The
justify-items property centers each grid item along the row axis within its containing grid area and align-
items aligns each item along the column axis. The .A{}, .B{}, .C{}, .D{}, .E{}, and .F{} rules set the
background color for grid items “A”, “B”, “C”, “D”, “E”, and “F” (i.e., <div> elements of class equal to
“A”, “B”, “C”, “D”, “E”, and “F”), respectively.
CHALLENGE 20.22
If you include the border property in the .A{}, .B{}, .C{}, .D{}, .E{}, and . F{} rules, what will the border
be applied to the grid items or the grid areas, and why?
CHALLENGE 20.23
Implement the example, but place more content in the grid items to observe the behavior. Also, what
methods would you use to make the items bigger without adding more content?
FIGURE 20.23 The effects of the main values supported by justify-self and align-self.
FIGURE 20.24 Example usage of justify-self and align-self.
The .grid{} rule in the example, again, makes the element of class=“grid” a grid container and its
children automatically grid items; sets its width and height; sets three columns and two rows; and sets a
border line-style. The .B{} rule sets the background color for grid item B and centers it along both row
and column axes within the containing grid area with justify-self and align-self, respectively. Notice that
the alignment properties are placed in the rule for the grid item and not in the rule for the grid container.
This is because it is the item that aligns itself within the container rather than the container aligning the
item. The .A{}, .C{}, .D{}, .E{}, and . F{} rules set the background color for items A, C, D, E, and F (i.e.,
<div> elements of class equal to “A”, “C”, “D”, “E”, and “F”), respectively.
CHALLENGE 20.24
In the example, why is the grid aligned flush to the top and left edges of the grid container?
CHALLENGE 20.25
Implement the example, but also center the grid in the grid container using the appropriate placement
properties.
CHALLENGE 20.26
Instead of using placement properties as instructed in the previous challenge, use the margin
property.
20.7 Ordering Grid Items
CSS allows two main types of ordering in relation to grid items: the order in which they appear in a grid
container and the order in which they are stacked when they overlap. The former is achieved using the
order property and the latter the z-index property.
CHALLENGE 20.27
Implement the example and experiment both with the order value and the order of the elements in the
HTML code to see the effects, and better understand the property and its possible applications.
In the example, the .grid{} rule defines the grid container and a three-column-three-row grid. In the .E{}
rule, the negative margin value extends grid item “E” at all four edges and the z-index of 1 positions it on a
higher layer than other items. The rules for the rest of the grid items simply specify background color.
Notice in the middle image that the layer position of grid item “E” is 5th, which is its position in the
HTML code.
CHALLENGE 20.28
Like in the previous challenge, implement the example and experiment both with the z-index value
and the order of the elements in the HTML code to better understand how the property works.
CHALLENGE 20.29
Modify the CSS code in Figure 20.28 to produce the output below:
20.8 Example Application of Grid
Apart from its use for structuring layouts, grid is useful for general structuring and alignment goals. For
example, as mentioned in Chapter 17, it can be used to align form controls. The example in Figures 20.30
and 20.31 shows how it can be used to achieve this, which in principle involves placing labels in one
column, controls in another, and buttons at the bottom, spanning all columns.
FIGURE 20.30 Using grid to layout and align form labels and controls.
FIGURE 20.31 Result of Figure 20.30.
In the example, the form{} rule defines a grid with two columns, and 5px column and row gaps. Notice
that the rows are not explicitly specified. When this is done, adding rows and sizing them is done
automatically for the grid items. In the form > label{} rule, grid-column places each <label> element that
is a direct child of the <form> element in the column that starts at the grid line named “labels” (i.e., first
column), grid-row places it automatically in the next available row, and justify-self aligns it to the end of
the column. Similarly, the form > input{} rule places all <input> elements in the “controls” column. The
.buttons{} rule places the element of class=“buttons” (the container for the buttons) in column 1 and the
next row, makes it span the two columns, and aligns it to the end. The “>“ selector is one of the selectors
introduced in Chapter 8.
CHALLENGE 20.30
The output below was created using the <dl>, <dt>, and <dl> elements and the grid. Using the
principle used in Figures 20.30 and 20.31, and your own content, create it. Hint: Remember from
Chapter 17 that the <dd> element has a default margin-left (or margin-inline-start) of 40px that needs
to be removed.
CHALLENGE 20.31
Implement the example in Figure 20.30. When you do, you should notice that the form is aligned to
the right of the browser window. How would you center it?
21.1 Introduction
The availability of computerized devices with different screen sizes and different capabilities, and the
need to deliver a website on as many of them as possible has led to the invention of various types of
solutions. These solutions include designing a fixed- structure layout for a specific class of screen sizes
and capability, designing a fluid layout that changes size according to screen size, and designing
responsive or adaptive layouts that resize and reorganize their components to suit a user’s device. This
chapter discusses these layout design approaches and how they are implemented, especially through CSS
flexible box and CSS grid layout properties.
TABLE 21.1
Example of the Variations in Device Screen Resolution and ppi as of Time of Writing
FIGURE 21.1 Fixed layout displayed in normal and reduce-width browser window.
FIGURE 21.2 Liquid layout displayed in normal and reduced-width browser window.
CHALLENGE 21.1
One of the quickest ways to understand how a responsive design works, if you are not already
familiar with this, is to actually see one in operation. To do this, visit a popular website, such as
news websites like BBC, MSNBC, or CNN, from a desktop or laptop, then change the width of the
browser window by dragging in or out the right or left side. You should notice the layout and the size
of the media elements continually change to fit the current window size. This is similar to what
happens when the site is displayed on different device screens. Adaptive designs can only be
experienced using a mobile device to access an adaptive site. Some airline websites are adaptive.
Notice that all the layouts contain the same elements, which are also in the same order, and that only
their sizes, shapes, and positions change. When the width of a browser displaying the desktop layout is
contracted, at a specified point, the layout changes to that for the tablet, and if the contraction continues,
the tablet layout changes to the mobile layout. Of course, in some cases, some elements that are present in
the design for larger screens may not be in the design for smaller ones. Also, just two versions of a design
may be enough: one for smaller screens and another for larger screens. Figures 21.4 and 21.5 show the
wider-screen and smaller-screen versions of the same Web page. Notice the different arrangements and
sizes of the design elements. Notice also that some elements are left out of the smaller version and the use
of a smaller, more compact menu bar in the form of a three-line menu navigation icon (known as navicon).
This icon is commonly used for all sizes of designs and further discussed in Chapter 25, where it is most
relevant.
In the wider screen design, when the user clicks a menu, a dropdown menu is displayed, from which
the user chooses a menu item and is taken to the corresponding page. In the smaller screen design, space
limitation makes the process of getting to the information page a little longer. When the navicon is
touched, the menus are displayed, and when the user touches a menu, a page is displayed that shows the
menu items, from which the user then chooses one and is taken to the corresponding page.
FIGURE 21.4 The wider-screen version of a responsive Web page layout.
FIGURE 21.5 The smaller-screen version of the Web page layout in Figure 4.
TABLE 21.2
Commonly Used Media Types and Features in RWD
The style rules for a media query can be specified with it, as shown in the earlier example, or in
separate stylesheets, in which case, the HTML <link> element is used to link to the stylesheets. Figure
21.7 shows how this is done. The first media attribute specifies the media query that says to link to the
“mobile-phone.css” stylesheet and apply the styles in it only if device-width is equal to or less than
479px. The second one says to use the “tablet.css” stylesheet only if device-width is equal to or greater
than 480px.
It is useful to note that width is different from device-width, which is the actual number of pixels that
make up the width of a screen. In some devices, these properties are the same, while in others they are
different. For example, some iPhone models have widths that are more than device-widths, due to the use
of retina display technology, which allows more pixels to be packed into the space for one pixel. In
relation to responsive design, it is width that is usually used, because it better determines what is
displayed. The devicewidth property is typically used only when specifically targeting mobile devices.
The other method of making use of CSS rules contained in separate stylesheets is through the @import
CSS at-rule. The rule allows you to import one stylesheet into another. As mentioned in relation to
typefaces and fonts in Chapter 13, the rule can be included in the <head> element of an HTML document.
However, it can also be used in a linked stylesheet by including it at the beginning of the stylesheet,
before any other rule. For example, to import a stylesheet named “menu.css” into another stylesheet, you
would include the following line:
@import url(“menu.css”);
This is done for every stylesheet to be imported. It maybe useful to know that there is no difference
between linking to a stylesheet or importing it, except that some older browsers may not support the
@import at-rule. A common approach is to link to an external stylesheet and then use the at-rule to import
stylesheets into it.
21.6.1.3.2 Breakpoints
Before media queries can be applied, decisions have to be made about points at which to apply them.
These points, as mentioned earlier, are known as breakpoints and derived in various ways. One way is to
determine them based on the screen sizes of current device classes, such as mobile phone (480px and
below), tablet (481-768px), and desktop (769-1232px). However, using common screen sizes does not
produce a versatile enough result, in that it carries with it the need for possible constant maintenance,
given that new screen sizes continually emerge and there is no way of determining what will happen in the
future.
A more generally preferred approach is to determine breakpoints visually, using the behavior of
content during resizing as guide. This typically involves opening the relevant mobile fluid design in a
desktop browser that is capable of displaying information about its current window size. Most browsers
are able to do this once you open their development tool. In Chrome, for example, the F12 key opens the
tool. Once the mobile fluid layout is opened, the browser window is narrowed as much as possible and
then slowly widened. As this is done, the point is looked for at which content layout changes significantly
and becomes unacceptable. This point is known as “where the content breaks.” It could be, for example,
the point at which whitespaces between elements become too wide, or the number of characters per line
is not within 45-75 (roughly 8-10 words), or font size becomes disproportionate to the rest of content, or
padding and margins of elements start to look unnatural. This point is the first breakpoint and two media
queries are required to specify how the layout should change when browser window size reaches it. One
query is for when window size is at the breakpoint or any size below it, and the other is for when it is any
size above. Each query basically contains the rules that specify the required layout. Once the media
queries are implemented, the browser is reset and the procedure is started again to look for the next
breakpoint, and so on, until all breakpoints have been found.
FIGURE 21.8 Illustration of a design displayed at the same size on a tablet and a wider desktop screen.
The number of breakpoints defined depends on the nature of content. For example, some content types
may require that layouts be created only for small and large screens if the same layout looks good and the
content is legible on, for example, both tablets and desktops. Indeed, a layout that suits tablet display is
often adequate for most desktop screens, since both devices are viewed at similar distances from the
eyes. It is important to know that a wider screen is not reason enough to make a design span the full width.
Content could simply be placed in the center and white space left at both sides, as illustrated in Figure
21.8. Alternatively, if content type permits, such as if there is enough text, and the screen is wide enough,
more than one column could be used, meaning, for example, that at the breakpoint defined for extra-large
screens, an extra column is added via media query.
Naturally, if a design is also to be displayed on much larger screens that are viewed from much greater
distances, such as TV screens, then additional breakpoints certainly need to be considered. In all cases,
an important factor that should not be overlooked in a responsive design is legibility, given that screen
size and the distance between the eyes and the screen can readily affect it. So, it is highly likely when
creating a responsive design that adjusting font size will be inevitable. Generally, the smaller the screen
size, the smaller the font size that would be most suitable, given that small screens are used close to the
eyes.
Where change in font size is necessary, size should be expressed in ems unit rather than in an absolute
unit in order to ensure both fluidity and proportionality with the font size set for the browser by the user.
In all, by basing the determination of breakpoints on content behavior, the chances of incurring the fewest
breakpoints are increased and future needs for maintenance are greatly minimized. To help with this
approach, there are now useful tools on the Web for finding breakpoints based on content. They typically
allow you to upload the relevant page, after which the sliders provided can be used to change viewport
width and height while the behavior of the content is observed for possible breakpoints. One of these
tools is responsivepx.
CHALLENGE 21.2
Why should a design not be as wide as it can be on a wide desktop screen?
FIGURE 21.10 HTML code for the fluid mobile design in Figure 9.
FIGURE 21.11 CSS code for creating the fluid mobile layout in Figure 9 from Figure 10.
The next step in the example implementation is to find the first breakpoint for a wider screen size. To
do this, the browser window is widened until the layout no longer seems right for the browser width. This
point is found to be around 600px, so, one media query is created for screen sizes that are equal to or less
than 599px (1px less than the point of the break) and placed at the beginning of the CSS code for the
mobile layout shown earlier in Figure 21.9. This is the query that is added: @media all and (max- width:
599px) {, with the rules for the mobile layout placed between the two curly brackets, as shown in Figure
21.12.
Next, a second media query is created for screen sizes that are equal to or greater than 600px and the
rules for the liquid layout for a wider screen size are placed in it, as shown in Figure 21.13. Figure 21.14
shows the result, which is the same as the one shown earlier for fixed and fluid layouts in Figures 21.1
and 21.2.
FIGURE 21.12 Specifying the breakpoint for the mobile layout.
FIGURE 21.13 CSS for producing a wider-screen layout with the HTML in Figure 10.
In the body{} rule in the media query, width makes the width of the <body> element (i.e., the page)
90% that of the browser window, margin aligns it 30px from top and bottom, and centers it horizontally,
color specifies the text color, font-family specifies the font, and text-align centers the text. In the main{}
rule, height sets the height of the <main> element and display makes it a flex container, making the
<aside> and <article> elements flex items. The header, aside, article, footer{} rule sets the background
color, padding, bottom margin, and corner roundness for the <header>, <aside>, <article>, and <footer>
elements. In the li{} rule, display changes the <li> elements from block level to inline-level elements
(removing the bullet points and displaying them on the same line) and padding puts some space between
them. The ul li a{} rule removes the underline decoration from the links. The main > aside {} rule applies
to the <aside> element that is a direct child of the <main> element. In it, margin-right puts some place
between the element and the next one to the right, height sets its height, flex says to stretch it at one time
the rate of the other flex items (in this case the <article> element), and order places it first. The main >
article {} rule applies to the <article> element that is a direct child of the <main> element. It sets the
height of the element, says to stretch it at four times the rate of other flex items (i.e., the <aside> element),
and places it second. The “>“ selector is one of the selectors introduced in Chapter 8.
FIGURE 21.14 The result of Figure 13 used with Figure 10.
Next, repeating the procedure for finding the next breakpoint, it is found to be around 1200px.
However, because the layout created for the 600px breakpoint also looks all right for this breakpoint
when stretched, no change is deemed necessary to the layout. It is also found that there is no need for the
layout to stretch beyond this point, irrespective of how much wider the screen becomes, as this will only
make the content difficult to read. So, to stop the layout from continuing to stretch once it gets to 1200px, a
declaration is added to the body{} rule to specify the maximum width for the <body> element, using the
max-width property, thus: max-width: 1200px;. The result is that a responsive design is produced in
which when the browser window is 599px wide or less, the mobile liquid layout is displayed, and as the
browser widens, the layout stretches until the browser window’s width gets to 600px, at which point, the
layout changes and then continues to stretch until the browser window’s width gets to 1200px, at which
point the layout no longer stretches because the <body> element has reached the specified maximum
width.
CHALLENGE 21.3
Combine the codes in Figures 21.10, 21.12 and 21.13, and add the max- width:1200px; declaration
appropriately to create the responsive design.
CHALLENGE 21.4
Add an aside column on the right of the example and add images (ads) to it.
22.1 Introduction
Once you are confident with using HTML and CSS, you are likely to be curious to improve your Web
design and development skills so that you can produce websites that not only look professional but are
also capable of providing complex functions. There are various Web languages that can be used to
achieve this, including those that enable more efficient use of CSS, such as Sassy CSS (SCSS), and those
that enable the dynamic manipulation of elements, such as JavaScript and PHP. To teach these languages
requires a whole book for each; so, this chapter only shows how they are used with HTML and CSS. This
should enable you to take free codes by others and use them with your HTML.
FIGURE 22.2 Using @extend in SCSS to remove the repetition in Figure 22.1.
The sites for CSS preprocessors, some of which are provided at the end of this chapter, usually tell you
how to install and use them. A quick search should also provide tutorials. The advantages of using CSS
preprocessors include:
Producing cleaner codes because they minimize repetitions.
Allowing the use of variables that allow long declarations to be represented with a variable that
can then be used repeatedly throughout a stylesheet.
Allowing code snippets and libraries to be shared through importing them.
Providing functions that allow you to do things on the fly by specifying conditions, such as “if
this, then do that”.
Producing CSS codes that are compatible across different browsers.
MIME type. Although it is not mandatory to include this for JavaScript, it is good practice to ensure
certainty. The script in the example writes “Hello World!” when the <body> element loads (i.e., when the
HTML document loads). The JavaScript statement more or less speaks for itself; the document is an
object, whose write method is used to display “Hello World” on the screen. The <noscript> element is
used to provide a message to users using browsers that do not support JavaScript or who have JavaScript
turned off.
When scripts are embedded in the <head> element, they are usually in the form of functions (sub-
routines), which are then called from within the <body> element. Figure 22.4 shows an example that does
the same thing that the code in Figure 22.3 does. The function, message(), is declared when the <head>
element is loaded and called when the <body> element is loaded, using onload=message() statement. In
essence, the statement says when the <body> element loads, to execute the function called message (). The
onload attribute is known as a global event attribute. As mentioned in Chapter 2, a global event attribute
is generated by any element.
FIGURE 22.5 Linking to an external script via placing code in the <head> element.
FIGURE 22.6 Linking to an external script via placing code in the <body> element.
Instead of spending time writing JavaScript codes, a common practice is to use JavaScript libraries,
which provide prewritten codes and are available from various sources on the Web. One of the most
popular libraries is the jQuery library. It is a single long JavaScript file that contains codes for common
functionalities and available in two versions (“jquery. js” and “jquery.min.js”) at various online sites to
link to or download. The two versions contain essentially the same codes. The former contains the long
version of the codes and jquery.min.js the minified version. The minified version has the elements that are
unnecessary for functioning (e.g., whitespace and comments), stripped out, and variable names shortened,
thereby minimizing size and loading time for the file, making it more suitable for production environments
where optimized performance is required. However, it is more difficult to read for the same reasons. So,
jquery.js is typically used during development when it may be necessary to look in the file for helpful
comments on usage.
To use the jQuery library, it is either downloaded into a folder and referenced locally, in which case
“jquery.js” or “jquery.min.js” is assigned to the src attribute of the <script> element, or it may be
referenced directly on any of the many Content Delivery Networks (CDNs), such as Google and
Microsoft, that host it on their server, in which case the relevant URL is assigned to the src attribute. The
following line, for example, links to the minified version 1.10.2 on Google’s host server:
src=“http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”
Once the library is linked to, any function in it can be used, using jQuery syntax, which is much easier
to use and less wordy than JavaScript. For example, the JavaScript code in Figure 22.7 produces the
same result as the jQuery in Figure 22.8. Notice that what is achieved with about four lines of JavaScript
code is achieved with only one line of jQuery code. The codes essentially say to make the background of
the Web page gray when the button is clicked. In the jQuery, the $, which is used to select HTML
elements, is used to select the <body> element, after which css is used to assign “gray” color to its
background.
FIGURE 22.7 This JavaScript does the same thing as the jQuery in Figure 22.8.
FIGURE 22.8 This jQuery code does the same thing as the JavaScript in Figure 22.7.
NOTE: Ready-made codes
Although it is important to know HTML and CSS as a beginner in Web design, it is not necessary
to know scripting languages. It may also not be necessary to spend time writing codes if they are
available on the Web to use for free. Using ready-made codes, for example, dCodes , from
dcodes.net, can save a lot of time as well as make the creation of complex features possible for
someone not very proficient in coding. All that is required is copying and pasting them as
required.
CHALLENGE 22.1
Write an HTML code to create a canvas, as shown in figure 6.9 in Chapter 6. Make the border
around it 1px thick, and then add the JavaScript below to the code to draw graphics on the canvas.
Hint: Add onload event to the <body> element thus: onload=“drawSquares();”, so that the
JavaScript is executed when the page loads.
CHALLENGE 22.2
Trying out the examples in this section requires a client-server setup. If you want to try them out, you
need to install a server on your computer. There are many free ones on the Web. A common one is
WampServer. Download and install the version compatible with your system. If the installation is
successful, an icon should be placed on the taskbar. Click it and then click “Put Online” on the menu,
if the server is not already online. If WampServer is not running, start it (e.g., from the Desktop) and
then put it online as described above. The initial aim is to ensure that the environment is correctly set
up to run both HTML and server-side scripts, in this case, PHP scripts. To do this, create a php
folder in the www folder that is in the wamp folder created during installation. Next, create the PHP
script in Figure 22.9, name it “hello.php,” and then place it in the PHP folder. To test if the setup is
working, type the following URL in the Web browser’s address window: http://localhost/ hello.php.
If the setup is working properly, “Hello World!” should be displayed. This means that the PHP script
in the server was executed. Now you can try out the rest of the examples in this chapter, if you want
to, and many others from the Web.
Like client-side scripts, server-side scripts can be written in one of various languages, including C++,
PHP, Python, and Ruby. The way it works (which was generally illustrated in Figure 1.3 in Chapter 1) is
that when a Web page requests a server-side script, the server fetches it, executes it, and then sends the
output to the Web client, usually in HTML. The output may also contain client-side scripts. Like client-
side scripts, server-side scripts can either be embedded or be in a separate file. However, when they are
embedded in HTML, the resulting document is not referred to as an HTML document and therefore does
not have the .html extension but the extension of the language used, such as .php for PHP. Figure 22.9
shows PHP embedded in HTML and Figure 22.10 the HTML document outputted and sent to the browser
by the server. The <?php.. .?> specifies that the line is a PHP statement and echo is a PHP command for
outputting content; in this case it outputs “Hello World.”
FIGURE 22.10 The output from the server after processing Figure 22.9.
CHALLENGE 22.3
In the previous challenge, you tried out the script in Figure 22.9. View the source HTML source
produced in the browser and see how similar it is to the one in Figure 22.10.
One of the functions that server-side scripts are used for is processing the data collected with a form.
Typically, processing would involve, for example, storing the data in a database or using it to retrieve
relevant data from the database and sending the retrieved data to the browser. Figures 22.11 and 22.12
show an example of how an HTML form and a server-side PHP script work together.
In the example, the form requires a user to type in their name and age. It also specifies that the script to
use to process the data is “personal.php” and that it is situated in the php folder. When the submit button is
pressed on the form, the data are packaged and sent to the Web server through the POST method where the
specified server-side script is used to process the data. The script, in this case, simply extracts each of
the form data, name, and age, and stores them in variables $name and $age, respectively, after which it
outputs “Hi,” plus a space, plus the content of $name, then a paragraph, and then “You are,” plus a space,
plus the content of $age, plus a space, plus “years old,” after which it sends everything to the browser. So,
assuming “Joe” and “35” are inputted for name and age on the form, respectively, the script returns “Hi
Joe” “You are 35 years old.”
FIGURE 22.11 An HTML form document that is linked to a server-side script in Figure 22.12.
FIGURE 22.12 The server-side script called by the HTML in Figure 22.11.
If the data are to be stored in a database, then the script will open one and insert them as necessary. If
the data are to be used to retrieve data from a database, then, similarly, the script opens one and uses the
data to search for matches, which are then sent to the browser. Examples of the general principles that
guide these operations are presented shortly. As mentioned in Chapter 5, to ensure that correct data are
sent to the server in the first place, it is normal and good practice to validate them (using HTML or
JavaScript) before submitting a form. All these and more are typical processes required for Web
applications that collect user-data, which include e-commerce and social sites.
CHALLENGE 22.4
To try out the example in Figures 22.11 and 22.12, create the HTML file in figure 13.11 in Chapter
13 and place it in the www folder in the wamp folder. Next, create the PHP script and place it in the
PHP folder. It is good practice to keep scripts separate from HTML files. Indeed, some Web host
services require this. Next, ensure that WampServer is running and online, as previously described,
and type the following URL in the Web browser: http://localhost/personal_form.html. A form should
be displayed. Complete and submit it. If everything works, you should get a message that includes
your form input.
FIGURE 22.14 The server-side script called by the AJAX function in Figure 22.13.
FIGURE 22.15 HTML and AJAX used to call the server-side script in Figure 22.16 to store form data.
FIGURE 22.16 Server-side script called by Figure 22.15.
CHALLENGE 22.5
If you are feeling up to it, try out the example in Figures 22.15 and 22.16. To do this, you need to
create the database and the table used in the example. Incidentally, you do not need to worry about
installing MySQL and PHP, because these were also installed automatically when you installed
WampServer in the earlier challenge. So, to create the database and the table, first, ensure that
WampServer is running and online, as described in the previous challenge, and then right-click the
WampServer icon on the taskbar and choose “MySQL console” on the menu. If you are asked for a
password in the MySQL window that appears and you never specified one during WampServer
installation and configuration, then simply press Enter to continue to the command prompt. Then,
from the prompt, using the commands and examples provided at the websites listed below, or at
similar MySQL tutorial sites, create a database named “zzforum” and “show” it to ensure that it is
created. Next, open the database (i.e., “use it”) and create a table called “users” that has the fields:
username (20 characters), password (20 characters), and postcode (7 characters). The fields are
all of type varchar. Again, “show” the table and display its structure to check that it is correctly
created.
http://www.pantz.org/software/mysql/mysqlcommands.html
http://www.tutorialspoint.com/mysql/mysql-create-database.htm
http://dev.mysql.com/doc/refman/5.7/en/tutorial.html
To add records to the table using the codes in the example, create storeData. html and place it in the
www folder of the wamp folder. Then create storeData. php and place it in the php folder in the
www folder. Next, enter http://localhost/personal_form.html in the browser to display the form.
Complete and submit it. If everything has worked properly, the record will be in the database when
you query the “users” table, using the appropriate SQL statement (e.g., select * from users;).
FIGURE 22.17 HTML and JavaScript-AJAX used to call the server-side script in Figure 22.18 for retrieving data from a database.
On the server-side, the posted data are passed to retrieved_Records.php (the script in Figure 22.18),
which opens the relevant database (zzforum), isolates the postcode, and uses it to search the “users”
table in the database for record that match it, using the mysql _ query () function. If any matches are found,
the records are stored in query-result variable. A table is then constructed with the data of the records,
stored in the record_string variable, and outputted to the browser, where it is stored in the
ajaxRequest.responseText property of the ajaxRequest object. Once the onreadystatechange event of the
object is fired to indicate that the status of the readyState property has changed and the response from the
server is completed, the content of ajaxRequest.responseText is placed in the <div> element of
id=“listRecords”, which automatically displays it. The innerHTML is a property that is used to access the
text between the tags of an HTML element.
FIGURE 22.18 The server-side script called by Figure 22.17.
CHALLENGE 22.6
The challenge here is to retrieve the data stored in the previous challenge. To do this, you simply
create the files in Figures 22.17 and 22.18 and place them in the appropriate folders in the
WampServer, as described, again, in the previous challenge. If everything works properly, when you
enter a postcode, the records with postcode that match it are listed in a table.
Although minification can be achieved manually, it is best automated and there are various tools, called
minifiers, available on the Web that specialize in minifying different Web languages like HTML, CSS,
and JavaScript, and they can be quite easy to use. Because minified codes are difficult to read, the usual
practice is to not minify until the final stage of development when everything is working as intended and
no further debugging is necessary. It is also recommended practice to keep the original unminified
readable copies, in case changes are required later.
Applying compression to minified codes and normal textual content is typically done using GZIP
compression, which can reduce text by up to 80%. All modern browsers support it and will automatically
ask servers to use it on the resources it serves. A server usually needs to be configured to enable the use
of GZIP. Your Web hosting company can duly advise you on the procedure.
23.1 Introduction
Visual designs are made up of different individual elements that range from text to static and motion
graphics. When these elements are combined appropriately according to certain well-grounded
principles, the result is a meaningful and aesthetically pleasing design. These qualities have been
recognized to play a significant role in how positively people judge, for example, a website. This chapter
discusses various factors and principles that can help in the creation of meaningful and aesthetically
pleasing visual designs.
23.4.1.1 Point
A point or a dot is a design element with a position but no extension. Although using it alone may provide
little meaning but perhaps intrigue, it is often when different types of points are grouped that they can
become very useful in creating a design. For example, they can be used to imply shapes, forms, and
patterns, as well as direct attention. Image “A” in Figure 23.1 shows examples of how points can be used
to create shapes. The point at the top left, in theory, should attract attention because it is relatively
isolated. The point in “B” shows a point that is also being used to attract attention. In theory, it should
attract attention because it is surrounded by angular shapes and of a significantly different color.
CHALLENGE 23.1
Using HTML and CSS, create a line of six points as shown in “A” of Figure 23.1. Also, say how you
would create from them the square of points shown in the image.
23.4.1.2 Line
Lines are one of the most basic, versatile, and commonly used elements of design, in that they are easy to
produce, can be in many forms (e.g., straight, curved, and irregular), and used in the composition of
almost any complex design. As a result they have many different functions in design, such as the
following, which might give you some ideas:
Organizing, separating, and connecting objects: Lines can be used to organize, separate, and
link elements to indicate order. Figure 23.2 shows some illustrations.
Creating textures or patterns: Figure 23.3 shows some simple patterns and textures. Textures
or patterns may be used, for example, as background or bars in very subdued colors that do not
interfere with the perception of foreground elements. Recall from Chapter 16 that patterns can be
produced using CSS gradient properties.
FIGURE 23.2 Use of lines for organization, separation, and connection.
CHALLENGE 23.2
How would you subdue patterns when using them as background?
Guiding the eyes to a point of focus: An actual or implied line can be used to lead the eyes to a
feature in a design or an image that may otherwise be missed, especially in content presentation,
as demonstrated in Figure 23.4.
Suggesting movement: Oblique lines can be used to suggest movement or dynamism. Figure
23.5 gives an illustration.
FIGURE 23.4 Example of the use of line for directing attention. (Image from http://www.freeimages.co.uk.)
CHALLENGE 23.3
Why do the position of the bicycle and the orientation of the gray square in Figure 23.5 suggest
dynamism?
Conveying specific feelings or moods: The direction and orientation of a line can be used to
imply certain feelings. For example, horizontal lines (as in shoreline) is believed to project rest,
calmness, stability, openness, and quietude; vertical lines (as in pillars) can suggest power,
strength, formality, height, dignity, restriction, and sometimes potential movement; diagonal lines
(as in a slope) can suggest vitality, dynamism, and agitation; curved lines (as in human body) can
suggest grace, beauty, elegance, movement, and sensuality; sharp jagged lines (as in cracked
glass) can suggest violence or destruction; and broken lines (as in gaps) can suggest
discontinuity. Using these different types of lines in an abstract design, for example, can help
communicate specific feelings or moods. Figure 23.6 shows some illustrations. When lines are
used to convey moods in Web design, they would usually be used in background image.
FIGURE 23.6 Examples of the use of lines for communicating feelings and tone.
CHALLENGE 23.4
State the mood typically associated with each of the following and how you would use lines to
convey them:
A Military website.
A website for organizing rave parties.
A website for bank or financing company.
Cruise holiday.
CHALLENGE 23.5
Do a search with the term “mood lines” to see more about the use of lines for creating mood.
CHALLENGE 23.6
While lines can be used in setting the mood for a design, so can colors, as previous presented in
Chapter 9. Bearing this in mind, state the colors you might use to compliment the use of the lines in
the illustrations in Figure 23.6 to help strengthen the intended mood and also justify your choice.
Providing emphasis: Underlining words in text gives them emphasis. Figure 23.7 shows the
words “basic” and “versatile” emphasized.
FIGURE 23.7 Examples of the use of lines for emphasis.
CHALLENGE 23.7
What is the possible problem with using underlining to emphasize a word on a Web page? If you just
want to underline a word without giving it any further meaning that user agents will recognize, which
HTML element and CSS properties would you use?
Also, which other HTML elements and CSS properties underline words when used?
CHALLENGE 23.8
How can the choice of color used for underlining help minimize the possible problem posed by
underlining words on a Web page?
CHALLENGE 23.9
The following are some other ways of using lines for emphasis, typically for headlines. They are
called “breaking the line” and “flanking”, respectively:
How would you create the two using HTML and CSS?
Defining shapes: Lines are central to the creation of shapes, although shapes can also be created
without lines. The types of shapes or designs that lines are used to create include logos and
background graphics. Figure 23.8 shows some illustrations of the different roles lines play in
creating shape.
FIGURE 23.8 Examples of shapes created with and without lines.
CHALLENGE 23.10
If you have to use shapes in your design and you have the choice of delivering them in JPG or SVG
formats, which would you use and why?
CHALLENGE 23.11
Like fashion, the use of shapes in Web design changes continually. To see a wide variation of how
shapes are used and for inspiration, do a search with terms such as the following, as well as your
own:
Shapes used in Web design
The use of squares in Web design
CHALLENGE 23.12
The design below was created using HTML and CSS border and flexbox properties. See if you can
create it.
Decorating designs: Lines can be used for beautifying a page or creating effects in various
forms, including dashed and dotted lines. Figure 23.9 shows some examples. In the left design,
lines are used to beautify the heading as well as depict shadows just by varying width and color.
In the right design, lines are used for the hanging bar, the chains, the logo, and to border the page
content.
FIGURE 23.9 Examples of the use of lines for decoration and effects.
CHALLENGE 23.13
Do a search on the Web, using, for example, the term “lines in Web design” to see various examples
of how lines are used.
CHALLENGE 23.14
Create the pattern below using HTML and CSS only.
CHALLENGE 23.15
Create a page design that is similar to the one below using HTML and CSS only.
23.4.1.3 Shapes
A shape (flat figure) within the context of design elements is basically an enclosed space created as a
result of the meeting of actual or implied lines. The three basic categories of shapes used in design are
geometric, natural, and abstract. Geometric shapes are structured and include rectangles, circles,
triangles, and polygons. Natural shapes (or organic shapes) primarily describe shapes that exist in
nature, such as those of leaves. They can also be manmade; an ink blob, for example, is a natural shape.
Natural shapes are typically irregular and/ or fluid at the edges. Abstract shapes describe approximated
or stylized versions of natural shapes. Symbols on signs, such as the shape of a man or a woman used to
identify toilets, fall under abstract shapes. Figure 23.10 shows examples of these different types of
shapes.
Traditionally, geometric shapes, particularly those with straight vertical and horizontal lines, are more
commonly used in screen designs than other types. This is mainly because squarish shapes tend to allow
optimal use of space and facilitate the organization of elements. However, more rounded organic shapes
do find applications in some types of websites, particularly in less formal websites, such as games and
children’s websites. Figure 23.11 shows some illustrations.
FIGURE 23.10 Examples of different types of shapes.
CHALLENGE 23.16
Because design ideas continually change, the best way to know of the current trend is to explore the
Web. So, do a search on the Web, using, for example, the term “shapes in Web design” to see various
examples of how shapes are used.
CHALLENGE 23.17
In addition to the CSS properties presented in this book for creating shapes, more properties have
since been released, but it was too late to include them in this book. Do a search for “CSS shape
properties” to find out how they make it easier to create shapes.
23.4.1.4 Size/Scale
Visual size and scale exist together and are similar, but different. Whereas size describes the actual or
usual physical dimensions of an element, scale describes the size of an element in relation to other things,
including its actual physical size. Scale, in essence, is relative. Size and scale can be used to accomplish
many goals in design, such as to emphasize the most important element, attract attention, create hierarchy
(i.e., order of importance), create perspective, organize elements, contrast two elements (e.g., adding
small text to a large element), and create interest and variety. Giving the right sizes to different elements
of a design, such as sidebar, header, and the main content area, creates scale, which if right contributes to
the achievement of the gestalt effect. Figure 23.12 shows the example of size and scale in use.
CHALLENGE 23.18
For which of the following types of websites would you consider the design concept in Figure 12
applicable, and why?
1. A website that provides services.
2. A website that sells products.
3. A website that sells books.
4. A slimming website.
5. A funeral home website.
23.4.1.5 Space
Space is the area on a page and there are two types from the point of view of design: negative and
positive. Negative space is empty space and what a design would normally start with. Positive space is
the space that contains an object. The ratio between the two is important in design. For example, a lot of
negative space can make an object more conspicuous while too little can make a design appear cluttered
and unattractive. Figure 23.13 illustrates negative and positive space.
Figure 23.14 shows how the ratio of negative and positive space can affect the look and feel of a
design. Notice how more airy the one on the left is. With a little imagination, it is possible to see how a
screen that looks like it would be more aesthetically appealing. Positive space is sometimes also referred
to as positive shape and negative space as negative shape.
The other use of space in design is in depicting the illusion of depth. The main techniques used to
achieve this include diminishing size and vertical position, overlapping, diminishing details, and linear
perspective. Figure 23.15 shows some basic examples.
FIGURE 23.14 Effects of negative and positive space in design. (Image from http://www.freeimages. co.uk).
FIGURE 23.15 Illustration of the techniques used for depicting the illusion of depth in design: (a) Diminishing size and vertical position, (b)
overlapping, (c) diminishing details, and (d) linear perspective.
Image A in the figure demonstrates the notions that the farther away objects are, the smaller they
become and also that objects that are smaller and higher on the screen tend to be perceived to be farther
away than those that are lower and bigger. Image B demonstrates that when an object is partially blocked
by another, it gives the sense it is farther back than the one blocking it. Image C demonstrates that as
objects move farther away, their details, such as color and value (i.e., tone), become less distinct both in
relation to other objects and the background, making us perceive objects that are clear as being closer
relative to those that are faded or indistinct. Image D shows that all lines will eventually come together at
a point on the horizon (called the vanishing point) that is farther away. The technique is used to create a
focal point in a design, where the most important object is placed. The lines used would usually be
implied, using, for example, objects’ alignment. Notice how in the illustration the eyes always seem to be
led to the center back of the design by the lines. Any combination of A, B, C, and D can be used to
produce an even stronger illusion of depth. Figure 23.16 shows an example of how overlapping is often
used in a Web page to create the illusion of depth.
FIGURE 23.17 Example of the use of value for creating the illusion of depth.
CHALLENGE 23.20
Using HTML and CSS gradient properties, produce an effect similar to the one in the right image of
Figure 23.17, filling the page with it so that it represents the background.
Different values can also be used to create contrast. The farther apart the values are, the more
pronounced the contrast produced. Contrast is especially useful for creating emphasis and attracting
attention. For example, a light figure on a dark background is automatically emphasized, and vice versa.
Figure 23.18 shows a design with different-value elements. The color of the button and the angular bar at
top-left is red and that of the larger rectangle, which is light pink, was derived from adding high value to
the red.
Another important role of value in design is its use in creating mood. In theory, lower values produce
designs that are often described as somber and quiet designs, while higher values produce lighter,
happier, more vibrant, more cheerful, or more playful ones.
CHALLENGE 23.21
How would you describe the mood projected by the design in Figure 23.18 and why? Also,
whatever mood you determine it to project, how would you make it project the opposite?
23.4.1.7 Texture
Texture refers to the surface quality of an object. It is both visual and tactile. However, it is the visual
dimension that is so far typically applicable in Web design. It can be described in various ways, including
soft, rough, smooth, wavy, and patterned. When using texture in a design, the aim is to match it to the
theme of the design. For example, a design about fashion might use the texture of fiber. It is important, of
course, that a texture does not overpower the foreground elements. For example, overpowering text can
compromise legibility. Figure 23.19 shows some textures as well as demonstrates the effects of
overpowering textures. Notice how overpowering the textures are in the left illustration and how after
they have been toned down the text is more legible in the right image. A better design also seems to have
been produced.
FIGURE 23.19 Examples of textures when they are overpowering and when they are not.
CHALLENGE 23.22
Which CSS properties allow you to create textures and patterns? Also, compare and contrast the
method with using image editing programs?
Symmetrical balance (also known as formal balance) is when visual weight is equally distributed on
either side of the central vertical axis of a design. It is achieved in two ways: pure symmetry and
approximate symmetry. In pure symmetry, identical parts are distributed on either side of the central axis
of a design. The design produced can be monotonous and uninteresting. In any case, this type of balance
seldom lends itself to too many practical applications, as it is seldom possible to distribute elements
identically about the vertical axis of a design. In approximate symmetry, the elements in the two halves
of a design are varied but still similar. Ways in which this is done include varying value, texture, and
shape. Designs that are balanced in this way are often more appealing and interesting. Figure 23.21 shows
an illustration each of pure and approximate symmetry.
In contrast to symmetrical balance, asymmetrical balance (also known as informal balance) occurs
when both sides of the central axis of a design are not identical but appear to have the same visual weight.
This usually happens when several smaller elements on one side of the axis are balanced by a larger one
on the other side, or smaller elements are positioned farther away from the center of the screen than a
larger one. Figure 23.22 shows some examples.
FIGURE 23.21 Illustrations of pure and approximate symmetry.
Other types of balance that are not as commonly considered but might apply to a design are vertical and
radial. Vertical balance is essentially balancing the visual weight on either side of the central horizontal
axis (i.e., balancing the top part against bottom). Typically, the bottom would be visually heavier than the
top. Radial balance is when elements are organized around the center of a design at equal distances.
Figure 23.23 shows an example.
It is important for a design to be balanced, as off-balance (or discordant) designs can cause
uncomfortable feelings, such as the feeling of motion. This does not mean, of course, that off-balance
designs are prohibited in Web design. Sometimes it suits exactly the requirement of an application. For
example, a design might be intended to project some artistic merits and be thought-provoking.
CHALLENGE 23.23
In what types of websites do you think off-balance designs might be applicable?
CHALLENGE 23.24
To see real world examples of the concept of balance in Web design, do a search on the Web, using,
for example, the term “concept of balance in design” or just “balance in design.”
23.4.2.2 Emphasis
Emphasis makes an element stand out and gives it importance (or dominance). This makes it attract
attention. For this reason, emphasis is used to control the attention of the user. Commonly used techniques
for implementing emphasis include contrast, placement, and isolation.
Figure 23.26 shows examples of visual hierarchy with simulated textual content. The image on the left
represents a screen full of plain text; the middle represents the same text chunked up, with sub-section
headings that have larger font size and bolder font style and text with jagged right edges; and the rightmost
adds short text in the form of comments and excerpts from the main text. It also adds light graphics in the
form of color blocks to provide more contrast.
CHALLENGE 23.25
Using HTML and CSS, produce the layout shown in the rightmost image in Figure 23.26.
CHALLENGE 23.26
In the rightmost image of Figure 23.26, what do you recognize the hierarchy of importance to be?
Also, give the reasons for your answer.
CHALLENGE 23.27
Which Web page do you think the design in Figure 23.27 will suit better: a homepage or any other
page, and why?
CHALLENGE 23.28
In which of the following scenarios do you think it would be beneficial to use isolation for emphasis,
and which element or elements would you isolate?
A page with a heading, sub-headings, and graphic illustrations that are cited in the text of the
page.
A form with minimum number of fields, a form with average number of field, and a form
with many fields. Each form naturally has a submit and a reset button.
A page where all elements hold similar level of importance.
A page of text with a heading and a block quotation to which you want to draw attention.
A page with an important paid advert.
CHALLENGE 23.29
Again, which Web page do you think the design in Figure 23.28 will suit better: a homepage or any
other page, and why?
CHALLENGE 23.30
Using HTML and CSS, how would you create a design similar to the one on the left in Figure 23.28?
Also, how would you frame an element to give it emphasis similar to the way shown in the right
illustration?
CHALLENGE 23.31
In which of the following scenarios do you think it would be beneficial to use placement for
emphasis, and which element or elements would you isolate?
A page with a heading, sub-headings, and graphic illustrations that are cited in the text of the
page.
A page where all elements hold similar level of importance.
A text page with a heading and a block quotation to which you want to draw attention.
A page with an important paid advert.
The button for closing a pop-up window.
23.4.2.3 Rhythm
Visual rhythm in design describes the timed, regular, or predictable occurrences of elements throughout a
design. It is in essence the repetition of elements in a design. An advantage of visual rhythm is that it
creates an easy path that the eyes almost instinctively follow. The movement of the eyes can be slow,
connected, and flowing, or abrupt and dynamic, or circular, depending on the frequency of repetition, the
types of repeated elements, and spacing. The repetition of similar elements or flowing circular elements
produces a design that makes the eyes move through it in a connected flowing rhythmic fashion, while the
repetition of unrelated elements produces a design that makes the eyes move in an abrupt and dynamic
manner. Figure 23.29 shows some basic illustrations that communicate this general principle. Notice that
each of the three designs has a different visual rhythm. Assuming they were producing musical beats, the
rhythm they would generate would be different. Notice also that out of the three designs, “C” has the most
pronounced accent. What this means is that if three different Web pages are designed to simulate the
rhythm of each of the designs, the page design that simulates “C” would be the easiest to find items on,
because the eyes will be guided from one point to another much more easily.
Rhythm is particularly important in long Web pages or when large amount of information is being
presented. Too bland a rhythm can result in nothing standing out more than others, making it difficult for
someone to locate things. This, in a sense, relates to the topic of emphasis through contrast discussed
earlier. Similarly, too much rhythm can make a page look chaotic. The best approach is to design a page
on the basis of how the information it contains is intended to be viewed. It may be that people are
intended to read quickly through, or go from one important part to another in the first place and then read
the less important parts if they wish. Figure 23.30 shows an example of rhythm being used in a Web page.
It is designed to guide people to the important parts of the page. The page basically presents titles of
articles and a brief description under each title. Notice how each article is presented using repeated
patterns of color, text style, design elements, and alignment. Notice also how the different sections have
different rhythm/ style but are not so different as to disrupt the overall feel or theme of the page.
FIGURE 23.30 An example of how rhythm can be used in Web page design to guide the eyes (Image from http://www.digg.com).
CHALLENGE 23.32
Which of the patterns in Figure 23.29 does the rhythm in Figure 23.30 most suit and why?
23.4.2.4 Proportion
Proportion describes the relationship between the sizes of visual elements of a design as well as between
the elements and the design as a whole. It is said to be good or harmonious when there is a correct or
desirable relationship between the elements. To help produce designs with proportions that are
considered harmonious, mathematically derived grid systems (or grid theories) have long been used by
designers. The practice goes back thousands of years, and although it was originally used for technical
designs, such as architectural designs, it has since been adopted and adapted in various areas of visual
design, including photography, videography, graphic design, and more recently Web design. Grid systems
(i.e., the ways grids are divided) vary widely. The two most commonly used are the golden ratio and rule
of thirds. While these grid systems are more typically used in shot composition in photography, film, and
art, they can sometimes find use in Web design, especially in content design. The grid layout model
discussed in Chapter 20 is mostly concerned with the precise placement of elements rather than where
best to place them for the purpose of aesthetics.
Another interpretation of how the golden ratio should be used involves placing the golden spiral on a
design and using it as a guide. The golden spiral, shown in Figure 23.34, is created through connecting the
opposite corners of the sequence of squares produced through repeatedly applying the golden-ratio-
division process to the smaller of the parts created after each process, until division is no longer
practical. In any case, given its relative complexity and the fact that Web page design does not need to be
perfect to the pixel, the strict application of the golden ratio is hardly necessary and generally not
followed. It is often only used as a guide.
FIGURE 23.34 The golden spiral created from golden ratio application.
CHALLENGE 23.33
Use the search term “web design golden ratio” or something similar to see various uses of the golden
ratio in designs.
23.4.2.4.2 Rule of Thirds
Like the golden ratio, the rule of thirds is hundreds of years old but still relevant. It is an easier system to
apply in a design than the golden ratio, in that it involves just dividing a space, such as a screen, into
thirds, vertically and horizontally; that is, into a 3 x 3 grid. As with the phi grid, it is believed that a
design would be more appealing if the areas of interest in the design are located along the grid lines or at
the intersections of the lines. Figure 23.35 shows the rule-of-thirds grid. Notice its similarity to the phi
grid. Figure 23.36 shows an example of the grid being used for positioning content.
CHALLENGE 23.34
Again, use the search term “web design rule of thirds” or something similar to see various uses of
the rule of thirds in designs.
23.4.2.5 Unity
Visual unity is achieved when the various elements of a design, such as typeface, shape, color, texture,
line, and space, agree and are in harmony with each other to produce a unified design (i.e., something that
the eyes see and the brain likes). It is a very important goal, as it helps project the central theme of a
design. It is an indicator that all the other design principles have been applied correctly in relation to each
other. Without visual unity, viewers may miss certain elements of a design, or may not get its essence or
connect with it. Unity is achieved using a collection of secondary principles, or methods, including
proximity, repetition, closure, continuation, and alignment, which are discussed next.
23.4.2.5.1 Proximity
When elements are positioned close to one another, they project the sense of belonging together. This can
also allow viewers to see a pattern, which can further enhance the connection with a design. To apply this
principle effectively, related objects are placed closely together, as shown in Figure 23.37. Notice how
the design on the right looks more compact and more structured. Many would see it to be more
aesthetically pleasing.
In the design example shown in Figure 23.38, it is clear that it is the proximity between the elements of
a group that causes the perception that they are in a group. Notice that even though the ovals and
rectangles are of different shapes, their proximity to each other gives the impression they are in the same
group. If all the elements in the design have been of equal proximity to one another, for example, it would
be ineffective to use proximity for grouping and another technique will have to be used.
CHALLENGE 23.35
How many groups can you identify in the design in Figure 23.38 that you think are due to proximity?
23.4.2.5.2 Similarity
Elements that look similar tend to seem to belong together. Grouping based on similarity is done using
three main properties: size, shape, and color/value. Figure 23.39 shows an illustration of each. Note that
the proximity of elements to each other can affect the effectiveness of this principle. So if it is difficult to
instantly group by size, color, or shapes respectively in the Figure, it is possibly because the relevant
elements are too far apart. The degree to which elements that are supposed to be in a group are similar to
the elements of other groups can also play a role, as does, for example, the orientation of elements.
FIGURE 23.39 Grouping using similarity in size, color, and shape properties.
Even when the proximity law is already used to group elements, the similarity law can still influence
grouping. In Figure 40, for example, even though the grouping of the elements is informed by proximity
between each rectangle and oval in a pair, all rectangles and ovals seem grouped by shape. For example,
you would instinctively expect information with the rectangles to be of the same type, and likewise for the
ovals. The use of the similarity law to group items is common with websites that sell products. It is what
is at play, for example, when the products in a section of the screen are of similar sizes even when they
are differently shaped.
CHALLENGE 23.36
In the middle and right examples in Figure 23.39, the property to use for grouping is not instantly
perceivable, what would you do to make it clearer in each case?
CHALLENGE 23.37
In Figure 23.40, identify as many groupings as you can and state the property on which the grouping
is based. Also, in what type of website can you see the layout applicable?
23.4.2.5.3 Repetition
Repeating elements, such as colors, shapes, textures, and lines, can create visual relationship between
different elements. Typically, only the key elements of a design need to be repeated to bind the design
together. This allows nonkey elements to be used to add variety, uniqueness, or character to a design to
make it interesting. Repetition, of course, equals consistency. For example, consistency in theme across
pages that deal with the same subject is a kind of repetition. Figure 23.41 shows a simplistic illustration.
The design on the left has no repetitions and therefore looks less unified compared to the one on the right
in which the key elements (i.e., the two sidebars and buttons) are identical.
23.4.2.5.4 Closure
Generally, complex objects are made up of smaller and simpler elements that the brain puts together as a
single entity. For example, a face is a collection of different elements, including mouth, nose, ears, and
eyes. The closure principle is based on the idea that if any of these elements is missing, the brain is
capable of filling them in to complete a picture. In visual design, the use of the closure principle can make
designs different and more interesting, provided care is exercised not to remove the vital parts of an
object. Figure 23.42 shows two examples, a triangle and circle with missing parts. When the closure
principle is used properly in a design, so that the arrangement of the elements that make up the design
projects a discernible shape, it can help unify a design.
FIGURE 23.41 Illustration of how repetition can affect the unity of a design.
23.4.2.5.5 Continuity
The principle of continuity is based on the notion that when we perceive a path, we tend to continue
looking along its direction, even when the path is intersected by another, until our attention is drawn by
something more significant, or we have reached how far we can go in that direction. This is how when
two lines intersect; we still can distinguish between them. In design, this means, for example, that if one
element points to or overlaps with another, the eyes tend to continue on from the first element to the next,
and so on. This tendency is usually exploited to direct a viewer’s attention. Figure 23.43 shows an
example of the continuity law being applied in the form of an arrow being used to direct attention to a
piece of information that is important but could not be placed in a more noticeable area of the page
because information about newer more important items need to be placed there. Because the continuity
principle essentially involves connecting one element to another, it can also help in unifying a design.
CHALLENGE 23.38
How do the rectangles in the example in Figure 23.43 convey the sense of continuity?
CHALLENGE 23.39
Again, in Figure 23.43, how else could the “Deal of the Day” sign be made to draw attention in
terms of changing its property?
23.4.2.5.6 Alignment
The alignment law involves arranging elements so that their edges or centers align with those of other
elements, creating more sense of harmony in a design. Figure 23.44 shows the difference good alignment
can make. The design on the right certainly looks more unified and more professional because its elements
are well-aligned.
Alignment can also be used in projecting a tone, as illustrated in Figure 23.45. Although there is
nothing particularly wrong with the alignment of the elements of the design on the left, it is probably too
symmetrical, too formal, and uninteresting. With a different alignment, plus an extra element to ensure
balance, the design becomes a little more interesting and less formal, as shown in the design on the right.
FIGURE 23.44 Illustration of the use of alignment in unity.
CHALLENGE 23.40
Given the guidelines on unity, do you think that the design on the right in Figure 23.45 achieves unity,
and why? If not, state how it might be made to achieve unity.
CHALLENGE 23.41
Which of the following design(s) do you think lack(s) unity/balance and why?
24.1 Introduction
The once totally desktop-centric approach to website design has changed a great deal since the emergence
of mobile devices and the need to deliver websites on them to provide more convenient ways for people
to access websites. However, many of the essential design features still remain the same and only their
size change as necessary, as shown under responsive design in Chapter 21. This chapter discusses these
features as they apply to websites in general and from the viewpoint of a standard screen size, while
Chapter 25 deals with mobile design specifically.
User experience is largely subjective, since it revolves around users’ individual perceptions and
responses to the features of a website, which can be different between users for the same website.
However, it is still possible to design websites in ways that evoke similar feelings in most users, and this
is the focus in the field of user experience. In order for a website to produce a meaningful and valuable
user experience, the expectations of the user must be met at least the most basic level, without any fanfare
or problems. Peter Morville visualizes the main factors that contribute to the achievement of this goal
with a honeycomb, an adapted form of which is shown in Figure 24.1, followed by the general guidelines
for addressing the factors in Web design.
Usefulness: This represents how valuable users perceive the features, functions, and information
provided to them. All information necessary for users to perform the tasks supported by a system
should be provided, without unnecessary extras.
Usability: The qualities that define the usability of a system are mainly learn- ability (ease of
learning), memorability (ease of remembering how to use it), effectiveness (how effectively it
can perform a task), efficiency (how quickly it can be used to perform a task), errors (number of
errors, severity, and recoverability), utility (provision of useful functions), and satisfaction (how
pleasant it is to use). To achieve these qualities, a website should be easy to use. Interaction
techniques should be familiar and standard so that they match users’ expectations. There should
be no unnecessary actions or difficult processes that tax the memory, such as calculations or need
to recall a lot of information. Errors should also be avoided. This is why proper testing
(discussed in Chapter 26) is important. If errors occur, it should be easy to recover from them.
Shortcuts should also be provided for frequently performed tasks, as should be feedbacks to
communicate what is going on, to users to make them feel in control.
Desirability: Design should be visually pleasing, easy to understand, minimal, and to the point.
This includes using design elements, such as image, branding, or identity, in a way that evokes
favorable emotion, or simply neutral emotion.
Findability: It should be easy to navigate and locate content on-site or off-site. This means
navigation should be intuitive and easy to understand. It should also be easy for users to find
solutions to problems.
Accessibility: Website should be accessible to users with disability so that they have similar
experience as others. How this is done with respect to how the features of a website are
implemented have been noted in various HTML and CSS chapters as appropriate.
Credibility: Website should be such that users trust you enough to believe what you tell them.
Because of the nature of a website to be used by total strangers who need to be convinced also by
total strangers, being able to design a website in a way that effectively conveys credibility is
especially important. Guidelines on this are presented in the next section.
Valuability: Everything done should be toward making user experience a valuable one.
FIGURE 24.2 Some comparisons between designs for children and adults.
FIGURE 24.3 Some comparisons between designs for different applications.
Similarly, Figure 24.3 shows two designs that are different because of the difference in application
goals. The one on the left is more suitable for a news media website than the one on the right, which is
more suitable for a personal website, or some alternative style website. The former is busier and more
formal while the latter is more spacey and casual.
Irrespective of differences in higher-level features or characteristics, most Web pages, at least
professional ones, can be said to comprise four main parts: header, footer, content area, and navigation.
This has already been implied earlier in Chapters 2 and 19-21. The header is the graphic strip across the
top of the page, the footer is the one that goes across the bottom, the content area is the space in-
between, and navigation design is varied. Figure 24.4 shows the typical design components of a Web
page. Within this design concept, there are myriads of variations. For example, links are embedded in
content and various elements are placed in different areas. However, Web design can still be broadly
categorized as comprising mainly navigation and content parts. An effective Web page design is therefore
best achieved by addressing each area specifically, using the various design principles discussed so far to
accomplish a design that is well organized, uses space economically, and communicates clearly at a level
that matches users’ capabilities.
In more complex Web applications than the examples, such as Google’s on-line word processor,
navigation may not only be to other pages, but may also involve opening new dialogue windows on top of
the main window. The more pages or functionalities (options) an application offers, the more the number
of navigation elements required in its interface. Where there are lots of elements, it is seldom practical to
display all of them at once without compromising the usability of an interface, so, dividing them into
groups is usually necessary. However, this can also result in a structure that contains too many menu
levels that can make finding contents or functions confusing or frustrating. Generally, any structure that
goes beyond the second level requires extra-careful planning from the beginning to reduce number of
levels, if possible. In other words, the design on the left in Figure 24.6 is likely to be easier to use than
the one on the right.
This means that a balance is important between having too many navigation elements on a page and a
structure that is too deep. A balance might involve, for example, embedding a linear structure in a
hierarchical structure. The fact that different navigation structures are best suited for different situations
also helps toward reaching a balance. A linear navigation structure, for example, is adequate for
presenting simple content or training materials and more suitable for children. In contrast, more complex
content and more matured users benefit better from hierarchical or network structures, because these
structures provide more options and flexibility.
As mentioned earlier, a combination of top, left, and bottom placement is the most common way of
locating the menus for a website’s navigation. When menus are located at the top area, they are usually
placed in and/or closely under the header, and when located at the bottom, they are usually placed in the
footer. Figure 24.7 shows an example of a permanent navigation design, identifying some standard
navigation elements that are commonly included, such as application ID, links to all sections, a “you are
here” indicator, utilities options, and a search facility.
Website ID: This identifies the website and is typically in the form of a logo or name, or both,
and placed at the top left area of the page/header in cultures that read from left to right, so that it
is one of the first things users see. For a target audience that reads from right to left, placement
would naturally be top right. Appearance should be different from the rest of the page, so that it
can easily attract users’ attention. When a logo is used and it does not indicate the name of the
website, this should be provided clearly (typically in bold) below or on either side. Figure 24.8
shows some examples of the variations used. It is useful and standard practice to also make
website ID a link to the home page, so that clicking it while on any other page takes users there.
Links to sections: These are features that provide access to the sections available on a site and
sometimes referred to as menus. They can be in a variety of forms; they can be buttons or
hyperlinks and placed across the top of the page or vertically on the left or right side. A common
convention when located in the top area is the use of tabs metaphor, such as shown earlier in
Figure 24.5. Guidelines on the design of tabs are discussed later in the chapter. A link can lead
directly to content or to further links, which can be presented, for example, through a mega drop-
down menu, also described shortly. One of the links to sections (typically the first) should be to
the home page, so that, in essence, every page has a link to the home page. For consistency, each
link should also match exactly the name (title) on the page it leads to and the name should stand
out clearly, be accurately descriptive of the page content, and positioned so that it is clear that it
applies to the content of the page. Making a page name stand out can be achieved via font style
(typically bold), font size, or color. Figure 24.9 shows some examples. Although the positions of
the names are centralized in the examples, placing a name at the top-left or top-right of a page can
also be effective.
Utilities options: These include essential facilities and information that are not part of the main
content, such as Shopping Cart, Your Account, About Us, Contact Us, and Help. The types of
utilities provided depend on type of application. They may be placed anywhere, but are typically
placed at the top of the page to the right. Ideally, four to five should be displayed at once to
ensure no item is difficult to find. Where there is not enough space to display all available
utilities, the most frequently used can be displayed and others grouped under one option.
Search facility: This feature provides means of searching the content of a site and is particularly
essential where there is a lot of content and compensates for the tendency for complex navigation
structures and content to lose users. It is placed near the top of the page, so that it is easy to see,
and should be in the form of type-in text box, not a link to another page or a dialogue window,
because users usually require immediate action. Also, a text box is what users are likely to look
for when they want to do a search. The text box should be wide enough to contain a few words
without scrolling, as scrolling makes it difficult for users to verify their input. It should also have
at least an associated button for activating the search. The simple convention is a box, button, and
the word “Search.” The word “Go” is also commonly used on the button. Figure 24.10 shows
some variations.
FIGURE 24.8 Examples of how the name of a site is used with a logo to form Site ID.
The use of fancy or unfamiliar words, such as “Find” and “Keyword Search” can be confusing, as they
might make users wonder whether or not they represent the same as a normal search function. If a search
of both a site and the Web is offered, any instructions to distinguish them should be short and straight to
the point, such as shown in Figure 24.11.
To let users search only a specific section for a term, the search function can also include the scope
option. Because of the tendency for users to miss the option, it is good practice to set default search scope
to “All,” as shown in Figure 24.11, so that the search is treated as normal. If scope option is offered, the
section searched by a user should be stated clearly at the top of the result page. Advice should also be
offered on the page on how to reduce scope when a search returns too many results. There seems no
evidence that an advanced search feature is usually needed, since most users are unable to use it; but, if it
is offered, it should be on a separate page, with a link to the page placed near the normal search function,
such as “more” and “tips,” as shown in Figure 24.12.
• “You are here” indicator: This feature is not strictly a component of navigation; rather, it is a piece
of information to help users determine where they are within the hierarchy of a site. One way to make it
perform this function effectively is through highlighting the currently selected page in the navigation area,
as well as ensuring that the item’s description matches the name of the corresponding page, as shown
earlier in Figure 24.6 with “Widescreen TVs” page. Highlighting can be achieved through different text or
background color, text styling, such as bold text, and special characters (e.g., an arrow). Breadcrumbs,
also known as breadcrumb trail, are a variation of “You are here” indicator and implemented in various
ways. Like a “You are here” indicator, for breadcrumbs to be effective, they need to stand out, but without
being overwhelming, since they only serve a secondary function. The last item of the trail (i.e., the
current page) should stand out from the rest of the items in the trail. This can be achieved by using
different font style (typically bold), different color, or negative contrast. Combining highlighting with
smaller but legible font size can further ensure that a breadcrumb trail does not compete with primary
navigation mechanism or content. Six different conventions are shown in Figure 24.13. As well as the
types of separators (“>“ and “I”) used in the example, other characters, such as “/” and “:”, are commonly
used.
The individual items on a breadcrumb trail, except the last (i.e., active) one, should be active
hyperlinks to the corresponding pages and look clickable; for example, they could be underlined or in a
different color, typically blue. This provides additional means for users to navigate back. Again, the
description of each item should match the name of the page to which it refers. To make the breadcrumb
trail easy to find, it should be placed in the top area of the page, after the header and the menus, but
before content. It can also be useful to place the phrase “You are here” at the beginning to help people
who are not familiar with breadcrumbs understand its function.
CHALLENGE 24.1
Redesign the navigation interface shown earlier in Figure 24.7, including all the navigation features
shown.
CHALLENGE 24.2
Tabs used to be implemented mainly through creating the images for the tabs in an image editing
program and then incorporating them in HTML. Now tabs can be done using HTML and CSS.
Without necessarily implementing one, what do you imagine the implementation logic will be to
implement one, given above guidelines; and which CSS properties do you think you might use?
Combining vertical and horizontal arrangements can also be effective. It makes the menu more
compact and also shows more items at a glance, thereby reducing reliance on short-term memory when
users are comparing the items. As well as this, it allows for the use of icons, which can aid faster
recognition of the functions of menu items. An example of the approach is the “Ribbon” design
introduced with Microsoft Word 2007. In Web design, the “ribbon” design is generally known as mega
drop-down menu. Figure 24.15 shows a smallish example.
To ensure that a drop-down menu behaves in a way that aids usability, response time when the cursor
points to a menu should not be too slow or too fast. If it is too slow it will feel like users are not in
control, and if it is too fast, there may be too much flickering when the mouse is moved across the navbar,
which can affect some users adversely. The general guideline is that it should start displaying after the
cursor has hovered over its label for about 0.5 seconds and finish displaying within 0.1 seconds of
starting. It should then remain displayed for as long as the cursor remains on it and starts to close about
0.5 seconds after the cursor has moved outside it or its label (or the navbar).
CHALLENGE 24.3
What are the advantages and disadvantages of using mega dropdown menu?
Another way a site map is used is for providing search engines information about the organization of
the content of a site. Web crawlers, such as Googlebot and Bingbot, which browse the Web for the
purpose of indexing it, read this file to more intelligently gather information about a site. A site map file
can provide useful metadata about the pages and contents it contains. The metadata provided about a page
could, for example, be the last time it was updated, frequency of update, and its relative importance to
other pages. The metadata provided about specific types of content, such as image, video, and audio,
could be type, license, and subject matter for an image, and include playing time and age-appropriateness
rating for video.
CHALLENGE 24.4
Is a site map necessary for every website? Give reasons for your answer.
CHALLENGE 24.5
Why would the design concept in Figure 24.17 not be good for the http://www.nfs.gov website site
map shown in Figure 24.16, considering only half of the site map is shown?
24.5.1.4 Footers
The footer of a Web page is like a supplement to the header and almost always has the same width to
ensure uniformity. The underlying design is also similar to that of the header, particularly in color scheme,
in order to maintain the site’s design theme. It could, for example, carry a scaled-down version of the
website ID. This is to maintain consistency and also distinguish it from the content area and attract users’
attention. It can be very basic or contain a lot of information, including links to further information. Its
purpose is to inform users and what is included in it to achieve this depends largely on the nature and
content of website. For example, for a site that stores content primarily in sections and sub-sections, the
footer may be in the form of just a site map with links to the sections and sub-sections, while for a site that
sells something, it may be in the form of links to information to remind users of promotional items and its
business policy. The following are some standard inclusions: date of the last update, copyright notice and
links to copyright policy, terms and conditions of use, privacy policy (if customer information is
gathered), contact us, delivery and return policy, FAQs and answers to them, text version of site (if
available), the Webmaster’s e-mail, and the site map. A call to action is also a common element placed in
footer. This could, for example, be a call to join you on social media or sign up for something, such as a
newsletter. Figure 24.18 shows a basic footer design.
CHALLENGE 24.6
Do a quick search on the Web, using, for example, the term “website footer” to see different kinds of
footers, observing how type of website influences the types of information included, as well as
design.
FIGURE 24.19 Screenshots of a big page displayed in different screen resolutions. (Image from http://www.freeimages.co.uk.)
What the Gutenberg rule roughly translates into is that when viewing a page the greatest attention is
often paid to Area 1, followed by Area 4, then Area 2, and possibly Area 3. A typical application of this
to content layout is to place elements in these areas according to their importance. For example, most
important elements (e.g., heading and high-value information paragraph) are placed in the top-left area,
the next important elements in the bottom-right area, the next important in the top-right area, and the least
important in the left-bottom area. Naturally, since the eyes pass through the middle on their top-left to
bottom-right journey, any element placed in the middle is likely to receive some attention and also
reinforces the pull of the reading gravity. A common practice is to place elements that call for action
from users (e.g., download buttons, links, and relatively important images) in the bottom-right area. Of
course, where a page does not contain heavy textual or evenly distributed and homogeneous content, the
Gutenberg rule is unlikely to apply. In such cases, the characteristics of the elements of the design (e.g.,
weight and color) plus the layout and composition of the elements are more likely to direct the movement
of the eyes. For example, if elements in the bottom-left area are visually emphasized they will probably
attract more attention than elements placed in other areas.
However, it is worth noting that as of time of writing there seems no strong empirical evidence to
support the usefulness of the Gutenberg rule in Web page layout, although a website (optimisation-
mavericks.blogspot.co.uk) claims to have done tests whose findings do. They found that when the
position of a product was rotated round the four quadrants defined by the rule, it received most attention
in Area 1, followed by 2, 3, and 4. They also found that Area 2 is effective for placing call-to-action
elements.
24.5.2.5.2 z-Pattern
The z-pattern theory suggests that when readers scan the content of a page, their eyes move from left to
right across the top of the page, then diagonally to bottom-left, and then to bottom-right, following a path
that describes a z-pattern, as illustrated in the left image in Figure 24.21.
Although like the Gutenberg rule there seems no empirical data to verify the effectiveness of the z-
pattern theory, it is a relatively common belief. Its implication for content layout is that important elements
should be located along the z-path. A typical application is to place elements that users are intended to
notice, or might want to see, first (e.g., logo, menu, and sign-on) across the top of the page; then the next
important elements (e.g., image) in the middle, where they should catch users’ attention as the eyes travel
diagonally down to the bottom-left area, where some useful but not urgent information might be located;
and then more information is located along the bottom (such as links to further information); and then at
the bottom-right area, elements that call for users’ action (e.g., download button) are placed. The right
image in the figure shows an example application. Note that the example is actually the template for the
Google page, which is not saying that the z-pattern is used. Indeed, it is not readily possible to determine
which rule, if any, has been used for a layout until the level of importance the elements are supposed to
have is known.
FIGURE 24.21 Illustration of the z-pattern and a rough example of its application.
FIGURE 24.22 The heatmaps from tracking users’ eyes while reading three Web pages. (From Nielsen, 2006, http://www.nngroup.com)
Accordions can be used to shorten pages and so prevent or minimize scrolling as well as make a page
neater by reducing the amount of text displayed at once. They can also be used instead of within-page
links, but this should be avoided, if possible, as studies have found that users tend to be confused when
they click a link and it does not take them to a new page. There are also issues with the accordion
technique itself. For example, having to click the headers to read their contents instead of just having all
the contents at once to scan through can easily begin to feel like too much work. Furthermore, they only
provide access to a bit of information at a time and, so, it can be hard, for example, to compare the
content of one header with that of another, because users are likely to forget what they have read in one by
the time they open the other, due to the limitation of short-term memory. Naturally, they require extra
attention in order to make them accessible to those who do not interact with Web pages in the
conventional ways. Printing the contents of pages that use accordions can also be tedious, in that the
content of every header has to be printed separately. This means that if they are used, and a page is likely
to be printed, a link should be provided to a separate file containing a full-length version.
24.5.2.6.3 Carousels
A carousel GUI essentially allows different pieces of content to occupy the same space at different times,
typically in a cyclical manner, either through user-interaction or animation, so that after the last piece of
content is displayed, the display starts again from the first. Usually, movement can be in left or right
direction, or up or down, but not necessarily, as carousel designs vary widely. Manual navigation can be
linear or nonlinear. Figure 24.26 shows some of the wide range of design concepts commonly used.
A carousel can be placed anywhere on a page. However, it is typically placed near the top of the
home page, especially when used to present, for example, important information that a company wants
users to see, such as the company’s brand or mission, promotions, and services provided. If it is for the
purpose of simply presenting content, such as a gallery of images or videos, then it can be placed
wherever is relevant.
While carousels are useful for saving screen space, they do have drawbacks that should be
considered before use. For example, research shows that users tend to ignore them for various reasons,
such as because they mistake them for adverts, or simply find them frustrating to interact with, since they
automatically rotate before users can read and digest their content. To make things worse, it can be
difficult to figure out how to stop them. This essentially takes control away from the user and can cause
bad user experience. Also, animated carousels can be annoying, since, like any animation, they
persistently attract attention and can be continually distracting. Although static carousels do not have these
drawbacks, users can miss the point that they are a collection of images and not know to look past the
currently displayed frame, if there is no clear suggestion to do this.
An altogether different alternative to carousels that is less likely to be ignored is a static hero image
(or hero graphic), which is basically a large image banner at, or near, the top of the home page. The
recommendation is that a hero image should be designed to attract attention (e.g., via bold and
complementary colors and font) and communicate clearly, using multiple media types, typically image and
text, to provide the same information. Providing the same information via multiple channels can help
improve the chances of quicker understanding. However, users can also ignore hero images, therefore it is
recommended that important information presented in a carousel or hero image is also provided
somewhere else.
FIGURE 24.26 Examples of carousel designs.
24.5.2.6.3.1 Guidelines for Designing Carousels In order for the full benefit of carousels to be realized
and for them not to cause usability or user experience problems, they have to be designed properly. The
following are some guidelines:
Limit the number of frames/slides to five or fewer, as users are unlikely to look at more than
this, or remember what they have seen after five frames, due to the limitations of short-term
memory. Of course, if there is a good enough indicator to help users determine what they have or
have not seen, such as numbering or changing the appearance of what has already been seen, then
this restriction may not be necessary.
All navigational aids need to be clearly visible and their function obvious in order for a
carousel interface to be easy to use. Basically, there should be a feature that informs of the
position of the currently displayed item in the carousel and, ideally, also serves the role of
nonlinear navigational aid. If this is not possible, the feature could just display the position of
the current item and the total number of items, such as “2 of 20” and 2/20.
If carousel is auto-forward (i.e., animated), the common behavior is for it to stop when the
cursor enters the display area. Also, when users click on a navigational aid, this should be seen to
indicate that they want to navigate the carousel manually and so the carousel should pause. It
should continue to do so until the cursor is no longer in the navigation area, since users are likely
to want to keep the cursor in the area while navigating the slides and spending variable times
reading each one. They are unlikely to prefer clicking an aid to navigate to a specific slide and
then moving the cursor to the display area each time to pause the carousel to allow them to read
the slide’s content.
Make text and images crisp-looking to improve the chances that users will pay attention to
them.
Keep information on each slide concise to give users fewer reasons not to read it.
CHALLENGE 24.7
Visit a few websites that use carousels, of which there are many, and critically assess them, given the
guideline above. Say how you can make them more user-friendly. If you do not know of any site with
carousel, visit http://www.wta.com, which has one as of time of writing, or try any other tennis site,
as these sites tend to use them.
Important words can be highlighted, using, for example, variation in font style (e.g., bold) or
color, as the eyes tend to stop on things that stand out.
Inverted pyramid style can be used, as in journalism, in which content starts with conclusion
before going into more details. In Web page terms, this translates into placing important facts near
the top of a page so that users can find them quickly. Multiple theories and studies suggest this is a
good idea.
Fewer words can be used than in printing without over-cutting or oversimplifying content.
Alternatively, content that cannot be made concise without compromising the intended message
can be provided in a way that is easy to print. Indeed, it is good practice to assume that users will
print anything that is more than half a page.
Number of ideas per paragraph can be limited to one, so that users can know just by reading the
start of a paragraph whether or not the paragraph is of interest and whether or not to skip it.
Paragraph should be left-aligned (or right-aligned for right-to-left writing mode) to facilitate
reading, as justification causes irregular word spacing (spacing between words) that make
reading difficult. See Chapter 14.
Grouping together of related information can be used. This can be done, for example, by
grouping under different headings; grouping by visual style (e.g., font style and color); or using
clearly defined areas or nesting. Figure 24.28 shows some illustrations.
Link titles: A description of where a link will lead should be provided when it is not obvious
through link text or surrounding text, as this helps users to make better navigation decisions. A
link title is the text that pops up when the cursor hovers over a hypertext link. The types of
information a link title should contain include the name of the section in the current site (or the
name of the site) to which the link leads, the kind of information that will be found at the end of
the link, and any other useful information. A link title should not be too long (about 60
characters), and because different platforms and browsers display them differently, it is useful to
try them out on different types.
CHALLENGE 24.8
A good exercise for knowing what is required for a good website design is see what bad ones look
like. There are many of these and which they change over time, because some of the designers
eventually realize the errors in their design. So, the exercise here is to search the Web for bad
website designs. You could do this, for example, using the term “bad website examples.” Most of the
sites that showcase these bad websites do not say what is wrong with the designs. See if you can
identify them, given all you have learnt so far. Also, pick one or two and try to redesign them.
24.6 Designing for Different Ages
A website that uses the various guidelines described so far in this chapter and various others would be
suitable for most types of users, as the result would be a website that is easy to use and accessible. A
website to which these guidelines are applied appropriately is likely to have, for example, a clean, well-
laid out design, good graphics that are used appropriately (if graphics are used), and font-size that
promotes legibility, all of which are favored by users of all ages. Where it is necessary to design an
application for a specific age group, because only that group is going to use it, refinements need only be
made in the form of adding features preferred by that group. The three main categories of users commonly
distinguished are children, teenagers, and adults, each of which has sub-categories that have their own
preferences. For example, children of age 3-12 years are typically further categorized into young (3-5),
mid-range (6-8), and older (9-12) children. So, designing for different ages amounts to designing for all
ages plus making necessary refinements. Table 24.1, adapted from studies by NN/g, shows some of the
differences between children, teenagers, and adults in terms of their preferences.
TABLE 24.1
Preferences of Different Types of Audiences
CHALLENGE 24.9
Select a children’s site, such as http://www.funbrain.com, and describe how it can be redesigned for
adult use.
25.1 Introduction
The term “mobile devices” describes a broad range of handheld computer technologies from small- and
big-screen smartphones to tablets. While many of the general guidelines discussed in previous chapters
for designing websites for desktop are also relevant to these devices, the differences in screen sizes and
capabilities between desktop computers and the devices make it necessary to design specifically for them.
Whether you choose to design a website specifically for a type of mobile device or you choose to use a
responsive design that adapts to different ranges of screen-size devices, you still need to be aware of how
to design effectively for each class of devices; recall from Chapter 21 that it is necessary to specify the
layout details for each of the relevant screen sizes, using CSS @media at-rule.
FIGURE 25.2 Illustration of a wordy content (left) and its presentation using progressive disclosure (middle and right).
CHALLENGE 25.1
What would you say are the problems with the design on the left in Figure 25.2?
25.3.1.4 Registration
Like in regular websites, early registration should be avoided in mobile websites or apps. Making users
go through any type of registration process (including providing just an e-mail address) on the first screen
of an app, before they can see what an app is about and decide whether or not they find it valuable enough
to commit, can be off- putting. This can be even more so than in regular websites, because of the extra
effort generally involved in inputting text in mobile devices. Another off-putting feature is a splash screen.
Although it may be novel the first time, it can quickly become a nuisance, in that it forces users to wait
unnecessarily.
FIGURE 25.3 Using the entire screen to display menus in mobile design.
CHALLENGE 25.2
It is impossible to cover all the variations and combinations of the principles illustrated in Figures
25.2-25.4. To get a better feel of mobile interface design, do a search on the Web for “mobile design
patterns.”
CHALLENGE 25.3
Design a mobile interface for a second-hand car sale company, assuming it sells different classes of
vehicles, such as cars, vans, and trucks, and in different models.
TABLE 25.1
Common Touch Gestures and Their Description
The animation component of touch gestures helps give a touch activity feedback and more realism.
Instead of the screen going directly from one state to another when a gesture is given, the states are
animated, as discussed in Chapter 18. The animation can be a simple transition effect or a more elaborate
and fancy animation. However, it is worth noting that fancy animations can become annoying after the
initial fascination they provide. Figure 25.5 shows an illustration of the content of the screen changing
from “1” to “2” after, for example, a swipe gesture, with the next content coming in from the right to cover
the current one. The middle state represents the transition phase.
CHALLENGE 25.4
Figure 25.5 shows an illustration of a screen content change after touch gesture. What sort of gesture
would you design to initiate it and why?
CHALLENGE 25.5
Do a search on the Web for tablet and iPad design patterns to see the broad varieties of design
concepts and help formulate your own ideas.
26.1 Introduction
While a small website project that involves only one person and has no time constraint may not require a
systematic approach for it to succeed, in large, complex Web projects that involve many people, including
clients and users, a systematic way of working can mean the difference between success and failure. This
systematic approach involves working in stages to ensure good understanding of the problem being
solved, the proposed solution, and the requirements of the target users. This chapter explains the concept
of systematic approach in Web development, using user-centered design (UCD).
CHALLENGE 26.1
Produce Figure 26.2 in textual form. Just imagine you are producing a table of content and structure
the steps accordingly.
26.3.3.2 Prototypes
A prototype is basically a rough version of a design idea that allows you to show the idea to users for
consideration and constructive feedback before investing effort, time, and money in full development. No
doubt it is easier and cheaper to make changes to a design idea early in development, when you are still
planning and before any codes are even written, than after a site has been fully implemented. Prototypes
ensure a product is produced that pleases the users and are typically high fidelity or low fidelity.
High-fidelity prototype: These are computer-based and usually allow user interaction, for
example, via mouse, keyboard, and/or touch. Because they are as close as possible to the
intended design, they are considered the best for collecting accurate user-performance data, such
as those that require responses from the system. They are also preferred when demonstrating
design ideas to clients.
Low-fidelity prototype: These are usually paper based and not interactive. They can be anything
from hand-drawings on paper to printouts of diagrams. Because they are easy and cheap to
produce, it is possible to create many alternative design ideas, thereby increasing the chances of
arriving at the best possible design. Typical examples are flowcharts, wireframes, and paper
prototypes, which are discussed next.
26.3.3.2.1 Flowcharts
Flowcharts have their origin in engineering and are visual representations of the flow of control (i.e., the
steps involved in a process). They describe how things work and are like maps of events. They can be
basic or very complex, depending on the complexity of the task being visualized. Figure 26.3 illustrates
the concept. It visualizes a basic process in which the user is asked for a password. After it is entered, it
is checked; if it is not correct, an error message is displayed and the user is asked for it again. The
process is repeated until a valid password is entered, after which the user is allowed to go on to their
page. The rectangles in the chart represent screens with messages and/or content for the user and can
contain anything, including images, video, and animation. The diamond, known as decision symbol,
indicates a decision-making process. The ovals are just terminals to indicate where a task starts and ends.
There are various other symbols designed to communicate specific functions.
A flowchart is used to visualize many different kinds of processes and often annotated in different
ways, so there are various types, but the goal is the same and that is to clearly communicate the workings
or structure of something so that everyone involved can create it and/or use it. In Web design, a flowchart
can be as basic as a diagram showing how the pages of a site connect to each other. This is why it is
sometimes referred to as a sitemap or a site’s navigational structure. For a complex website, flowchart
can also include script-generated pages and loops to illustrate paths of user-interaction or decisions. Path
of user-interaction or decisions is also sometimes referred to as user flow or user journey. Figure 26.4
shows two different navigational structures for a basic personal website. The left design shows a linear
navigation structure in which users can only go from a page to the one that is adjacent. The right design
shows a network navigation structure that allows users to go from one page to any other. In either
design, the site can be entered from any page just by, for example, typing the address in a Web browser.
Naturally, the design on the right makes more sense for a personal Website, as users are more likely to
want to choose specific pages than navigate linearly.
FIGURE 26.4 Two different navigation designs for the same site.
In the example, if in order to go from the home page to any of the other pages a password is required,
then how that process should work and the pages/messages that will be displayed are included in the
flowchart. These could directly be part of the chart, or an appropriate symbol could be used to represent
it and the full details presented separately.
CHALLENGE 26.2
The navigational structures in Figure 26.4 imply the types of navigational components or aids that
each page on the site must have. State them. Also, produce a user flow chart for going from home
page, to product page, adding a product to cart, and completing purchase.
26.3.3.2.2 Wireframes
A wireframe is a skeletal diagram, typically with no color or graphics, which is used to specify the
details of everything that will enable a screen to be created as intended. These can include the layout of
elements, color scheme, text color, font type, font size, media usage and intended treatments, and
interactivity details, such as the description of actions possible from the screen. If videos or animations
are involved, for example, the scripts to be spoken or used in voice-overs, if any, are included. Using the
flowchart on the right in Figure 26.4 as reference, Figure 26.5 shows the wireframe of a possible design
concept for the home page. The term “storyboard” is sometimes used to refer to a wireframe or a
collection or sequence of wireframes.
CHALLENGE 26.3
Create the wireframe for the home page for the flowchart on the left in Figure 26.4, assuming you are
presenting the same content as the wireframe in Figure 26.5.
FIGURE 26.5 Wireframe for the home page design of the flowchart on the right in Figure 26.4.
FIGURE 26.6 An example of a mobile application paper prototype. (Image from nngroup.com.)
CHALLENGE 26.4
Conduct a cognitive walkthrough for viewing the details of a camera at http://www.amazon.co.uk,
without going on to buy it.
CHALLENGE 26.5
In the case of a navigational button and an image, how would first heuristic on the list be satisfied,
and what aspect of HTML and/or CSS can be used to achieve it?
26.3.4.1.1.6 Expert Review—Key stroke-Lev el Model Method The Keystroke-Level Model (KLM) is
one of evaluation methods known as predictive modeling methods. These methods involve experts using
formulas (known as predictive models) to predict user-performance at completing various types of tasks
on various systems. This means that they can be used, for example, to evaluate whether a system is
performing to standard, or compare the efficiency of different systems at performing the same set of tasks,
or compare and choose between different user-interface designs for a proposed system, such as in terms
of the effectiveness of their layouts for performing the same task.
KLM is the simplest and the most commonly used of the predictive models and one of a class of
predictive methods known as Goals, Operators, Methods, Selection (GOMS) rules. This is why KLM is
also referred to as KLM-GOMS. It uses predefined classes of operators, each of which has estimated
execution time assigned to it. This makes it possible to use the model to predict and compare the times it
will take to perform a task on a system when using different sequence of actions. This is particularly
useful for determining which of the different ways of performing a task is the most effective, or which
design is most effective for performing a task. The original KLM defines the following six classes of
operators and execution times:
K For single key-press
Best Typist (135 wpm): 0.08 seconds
Good Typist (90 wpm): 0.12 seconds
Poor Typist (40 wpm): 0.28 seconds
Average Skilled Typist (55 wpm): 0.20 seconds
Average Non-secretary Typist (40 wpm): 0.28 seconds
Typing Random Letters: 0.50 seconds
Typing Complex Codes: 0.75 seconds
Worst Typist (unfamiliar with keyboard): 1.20 seconds
P—For pointing the mouse to an object on screen: 1.10 seconds
B—For button press or release (e.g., mouse): 0.10 seconds
BB (or P j )—for button click (e.g., mouse), that is, pressing and releasing: 0.20 seconds
H—For moving hands from keyboard to mouse or vice versa: 0.40 seconds
M—For mental preparation for performing an action: 1.20 seconds
R (R(t)) —For system response, where the user has to wait when carrying out a task
T(n)—For typing a sequence of n characters on a keyboard (n x K sec)
To use the model to evaluate a system, the evaluator first chooses a representative task and determines
the different ways in which it can be completed, or how users might complete it. Next, any assumptions
are listed. For example, if the task is to delete an item, assumptions might state whether or not the
Trashcan (Bin) is visible on the screen and can be pointed to, and that only one item will be deleted. They
would also include stating the start and end position for a task, such as whether the hand starts and ends
on the mouse, and where the cursor will end up at the end of the task. Next, the sequence of keystrokes-
level actions (i.e., instructions) for each approach, such as “Point to file icon” and “Press and hold mouse
button,” is listed, along with the corresponding operators, such as K and P. If necessary, operators are
included for when users must wait for the system to respond, or have to stop to think. Next, the execution
time for each operator is included and the total time calculated for each method. The one with the smallest
execution time represents the most efficient method of completing the task. This procedure is repeated for
all representative tasks. The following example is the sequence of operators required to accomplish the
task of dragging a file icon to the Recycle Bin that is visible in Windows platform and the total execution
time for the task.
1. Point to file icon (P)
2. Press and hold mouse button (B)
3. Drag file icon to Recycle Bin icon (P)
4. Release mouse button (B)
5. Point to original window (P)
Total execution time = 3P + 2B = 3 x 1.1 + 2 x 0.1 = 3.3 + 0.2 = 3.5 sec.
The main advantage of the KLM is that it allows decisions to be made about systems without the
necessity for expensive procedures and the sometimes difficult task of conducting evaluation using users.
The main downside is that the execution times used are only estimates that may not hold in real-life work
environments. They do not, for example, make allowance for errors or various factors that influence user-
performance when performing a task, such as fatigue, mental workload, and working style; nor do they
make allowance for the fact that users do not always carry out tasks in a predictable sequential order. For
these reasons and other limitations, predictive models in general are most useful only when tasks are short
and clearly defined, with limited variations in the way they can be performed.
CHALLENGE 26.6
Conduct a KLM evaluation for accomplishing the task of selecting a file icon and pressing the Delete
key to delete it, and then compare the result with the example above and state which one is the more
efficient method. Remember to state any assumptions made.
26.3.4.1.1.7 Expert Review—Fitts’ Law Fitts’ law is another predictive modeling technique used in
usability testing. It is a law that suggests a relationship between the time required to move from one point
to a target, the distance to the target, and the target’s size. A useful piece of information from this is that
the bigger a target, the more easily and more quickly it is to reach it, perhaps because people are more
confident about their judgment and therefore more apt to advance more quickly than move at reduced
speed. In essence, it provides the primary reason for why graphical user- interfaces with bigger buttons
and icons are easier to use than those with smaller ones. The law is represented mathematically in various
ways. Figure 26.7 shows an example of one of the simpler ones.
CHALLENGE 26.7
Given the message of Fitts’ law, how might it help during design, even without engaging in formulas
and calculations?
Web accessibility, detailed recommendations on when and how its evaluation should be conducted are
provided on W3C WAI’s website. As a result, only summaries of the key elements are discussed here.
Evaluation of accessibility serves numerous purposes. One is to help identify during the development
of a website any problems that might compromise accessibility. Another purpose is to determine
conformance to Web accessibility guidelines, which may be proprietary, government guidelines (such as
America’s Section 508), or W3C WAI’s WCAG. Evaluation of accessibility can also be to monitor an
existing site on an ongoing basis to ensure accessibility is maintained. It is particularly useful when done
throughout the development of a website, as it makes it possible to identify accessibility problems early
when they are easier to correct or avoid.
The comprehensive evaluation of a website to determine whether it complies with all accessibility
guidelines can be complex and time consuming. However, several automated and semi-automated tools
are available that can speed up and facilitate the process. Unfortunately, though, these tools are usually not
capable of checking all guidelines; therefore, manual evaluation by a knowledgeable human (ideally the
author of the relevant website) is essential. Manual evaluation can help spot false or misleading results
produced by automated tools and can also check compliance with guidelines that are better judged by
humans, such as the use of clear and simple language, and ease of navigation. Naturally, evaluation can
involve users as well as the use of some of the evaluation techniques previously discussed in this chapter.
In particular, the involvement of people with disabilities is highly recommended where possible, as the
concept of accessibility is largely about providing access to them. In addition, the involvement should be
as early as possible to ensure a smooth and efficient development process.
Before evaluating a website for accessibility, a preliminary review is usually conducted to determine
whether there are indeed any accessibility problems with the site. This is like the evaluation itself, but
less rigorous; for example, only sample pages are reviewed. The output from the process is a report that
(1) summarizes both positive and negative findings, and (2) recommends what needs to be done next (e.g.,
a full compliance test) and how identified problems can be resolved.
FIGURE 26.8 Part of an accessibility report, showing details of problems found and recommended solutions.
CHALLENGE 26.8
Go to http://www.w3.org/WAI/ER/tools/complete.html, or search for Web accessibility evaluation
tools, choose at least two tools, and use them to evaluate a simple Web page. Compare both tools in
terms of features, ease of use, and usefulness of report output.
It is common practice to record these types of interviews and analyze them later; and even ask people
to explain their comments later, if they are not clear. This form of interview is particularly useful when
gathering requirements for a product that is going to be used by different groups of people for different
purposes. One disadvantage is that social pressure within a group can inhibit some people’s ability to
speak their minds, which may limit the scope of the collected data.
26.3.4.4.2.2 Questionnaires Questionnaires are similar to interviews, in that they use both open and
closed questions, depending on the intended goal. However, with questionnaires, questions need to be
more clearly worded, particularly as they are usually completed without an interviewer around to clarify
any ambiguous elements. Questions also need to be specific and, if possible, closed, with a range of
answers offered, just as described under structured interviews, including the “none of these” or “No
opinion” option. Having questions and answers of this nature ensures that a questionnaire can be
completed more accurately and collected data analyzed efficiently. Questionnaires are especially well
suited for collecting data from a large number of people, because they can be distributed widely, even
though different versions might be necessary for different populations of respondents. They can be used on
their own or together with other techniques of data gathering, such as interviews, meetings, and
observation. Because many people tend to be warmer to these other methods than to questionnaires, the
benefits of questionnaires are attainable only when people are willing and able to complete them. If they
are not, then a structured interview is usually used.
Questionnaires are typically divided into two general sections: the section that gathers demographic
information about a respondent (e.g., age, gender, place of birth, and experience level in subjects) and the
one that gathers the respondent’s opinion about what is being evaluated. Demographic information is
usually useful for putting questionnaire responses into context. For example, it can reveal that more
females like something than males. Any of these sections, of course, can be further subdivided. For
example, sometimes, a section for soliciting additional comments is added. A well- designed
questionnaire should incorporate features that encourage respondents to complete it. For example, there
should be clear instructions on how to complete it, and it should look good. This can be achieved via
appropriate text styling, formatting, and ample white space. It should also be short: typically 10 to 15
questions long or less.
In order for responses to be as accurate as possible, the type of response allowed for a question must
match the question. These response types are referred to as response formats and there are different
types, each of which is suitable for a particular type of question. For example, an open question requires
space for respondents to write (or type, in the case of on-line questionnaires), while a closed question
requires a set of answers from which to choose. Questionnaire data can be in written form or in electronic
form that is stored in a database. As with interviews, opinions and responses to open questions are
qualitative, while responses to closed questions and responses that are in numbers are quantitative. The
following are some commonly used response formats.
Ranges and check boxes: These are commonly used to group quantities. Figure 26.10 shows an
example usage. In this case, respondents are expected to be between the ages of 16 and 35.
Notice that the ranges do not overlap, such as in 16-20, 20-25, as this can cause confusion.
Notice, also, that the intervals are not equal and do not have to be. For example, the ranges in the
figure could be Under 16, 16-35, and Over 35.
Sometimes, ranges are combined with check boxes, as shown in Figure 26.11, which respondents tick, for
example, instead of circling their selection. Naturally, check boxes are used in various other ways,
such as to present yes, no, and don’t know options.
However, in on-line questionnaires, check boxes are used only when responders are required to make
multiple choices. Where only one selection is required, it is radio buttons that are used, as shown in
Figure 26.12 .
Ranking: In this method, respondents are asked to rank the items of a list based on some criteria.
Figure 26.13 shows an example usage of ranking.
In on-line questionnaires, input boxes may simply be provided for responders to type in their choices, or a
dropdown list of numbers may be used. Scripting can be used to ensure that a ranking is used for only
one item.
Rating scales: A rating scale is basically a set of options that vary in degree, such as strongly
agree, agree, undecided, disagree, and strongly disagree. These scales are well suited for getting
respondents to make judgment about things. Two of the commonly used, Likert and semantic
differential scales, are described here. Likert scales use a set of statements that describe levels
of opinion, emotion, and so on. They are used for measuring strength of feelings, opinions, and
attitudes, and because of this are commonly used to evaluate subjective measures (experience),
such as user satisfaction with products. Figure 26.14 shows two different versions of Likert
scale. A particular strength of Likert scales when they use numbers, as in the top example, is that
they allow data to be recorded quantitatively, making it easier to analyze the data statistically.
In contrast to Likert scales, semantic differential scales use pairs of words that represent extremes of
possible options and respondents are asked to place a cross in one of the positions between the two
extremes. Figures 26.15 and 26.16 show some examples with 7-point scales.
Generally, rating scales use 7-, 5-, or 3-point scales, or a 9-point scale, as used by Questionnaire for
user interface satisfaction (QUIS), a well-tried and tested tool for evaluating user satisfaction on various
interface elements. The matter of which is the best is debatable. For example, while one argument states
that scales with many points help people to discriminate better, another suggests that people might be
incapable of accurately discerning between many points and therefore scales with more than five points
can be unnecessarily difficult to use. Some recommend using a small number when possibilities are very
limited. When it comes to the matter of odd and even number of points, both have positives and
negatives. Mainly, odd number of points provides a central/neutral point, thereby providing respondents a
way out, whereas even number of points forces them to make a stand, even when they are unsure. On-line
rating scales typically use radio buttons, drop-down menus, and even sliders.
27.1 Introduction
Essential to the success of any project, private or commercial, is how well it is managed at all stages,
from the first meeting with a client to the final sign-off. The same is true for a website development
project, and it is particularly so because of the different types of tasks that need to be juggled. This
chapter discusses what the stages of a Web project entail.
Basically, project management ensures that the various elements that are essential for the success of a
project are defined and managed correctly, and the criteria that broadly determine this success are
primarily:
Whether the client’s requirements have been met.
Whether the project is within budget.
Whether the project is completed on time.
To ensure the accomplishment of these criteria, project management defines goals that are said to be
SMART (i.e., Specific, Measurable, Attainable, Realistic, and Time- bound). These guidelines, which
vary according to context, are used to set and assess project goals in order to maximize their chances of
success.
A specific goal is one that is clear and precise rather than general. It addresses the “W” questions,
which are what, where, why, which, who, and when of the goal. It should state what will be
accomplished, where it is to be accomplished, why it needs to be accomplished (including, for example,
the benefits it will bring), which requirements and constraints are considered, who will be involved, and
when completion is expected. In some cases, goals may even be as concise as simply stating what is
expected, when it is expected, and how much it will cost.
A measurable goal is one that has numeric or descriptive ways of measuring progress toward its
achievement as well as its achievement. This is important in helping to stay on track and meet necessary
targets. Measures can include quantity, quality, time, and cost. The typical questions to ask in relation to
them include how much or how many, and how will we know when this is accomplished.
An attainable goal is one that is realistic and achievable, given available resources, such as
timeframe, budget, abilities of team members, and control over prevailing circumstances. Evaluating
whether a goal is attainable may also lead to the discovery of a more efficient way of achieving it.
Typical questions to ask include “How can the goal be best accomplished?”
A relevant goal is one that is beneficial to the entity for which a project is being undertaken. It may
also be linked to any other relevant goal. A typical question to ask is whether a goal benefits the entity in
any way, directly or indirectly, presently or in the future, and whether the right people will handle it.
A time-bound goal is one that has a definite target date for completion as well as for each milestone in
a project. This helps focus both individual and team effort on the completion of every milestone as well
as prevent a project from slipping behind. Typical questions repeated for every milestone include how
much work is required to achieve a goal and how much of it can be accomplished in a working day.
Once goals are defined, various project management tools and techniques are used to plan their
achievement, as well as to monitor, control, and evaluate them. The types of goals defined and the
difficulties they pose depend largely on the nature of the area of project. In Web projects, what can be
straightforward managerial activities in other types of projects can become quite complex, because
different media types are involved. This can mean that people from different disciplines are involved who
are experts in their own rights, have different work practices, and more often than not have contrasting
views of what constitutes appropriate interpersonal behavior. Additionally, the subject of quality control
can be far from simple, particularly as there is no one right media quality, since whether or not a quality is
suitable depends on several factors, such as media type and context.
Furthermore, where all media assets are not created in-house, there may be the issue of seeking out
people to get their permission to use their works, and if a Web application is for use in some areas, this
may require extending the scope of management. For example, if an application is for use in the area of
marketing and business, this may mean that business and marketing elements need to be incorporated in
managerial activities. Adding to this the increasing number of different technologies on which the same
Web application can be delivered, such as Web, mobile devices, iPad, iTV, and kiosks, the difficulty of
managing a Web project is further compounded.
CHALLENGE 27.1
In the triple-constraint model, describe what you consider represents quality in an interactive Web
project.
27.3.1.1 Brainstorming
Brainstorming is a random, free-thinking, but powerful technique for creating new ideas and solving
problems. It is usually the first important creative stage of project management, but it can also be used
at any stage of a project. Because it involves the people involved in a project working together,
brainstorming also has the benefits of developing and motivating a team, as well as encouraging creative
and free thinking. Although it is random, it is important for it to be structured and to follow
brainstorming rules. The project manager, or a designated person, will usually ensure this. The rules are
generally that all ideas are welcomed, and no ideas should be criticized; the more the ideas, the better it
is; and everyone should try to build on the ideas of others. Ideally, the number of participants should be
less than 10 to ensure manageability. The participants should also be diverse in background, if possible,
to broaden the scope of ideas, although it is important that they have some subject-matter expertise in
order to facilitate manageability.
Brainstorming consists mainly of determining the aim of a session, conducting the session, and acting
on the actions decided. The aim of a session would be to solve a problem, which would have been
identified prior to the session. To start, the project manager ensures that everyone understands and agrees
on the aim of the session and also knows the rules. The aim should be kept simple in order to ensure that
the brainstorming does not get too unwieldy. It may also help to present aims in question form. To
simplify an aim, it can be divided into smaller objectives, with time limits given to each. A session
should not be too long, as this can be tiring and unproductive. If satisfactory ideas have not been found at
the end of the set time limit, the session should be postponed and the participants encouraged to think
about the problem at hand for the next session.
The brainstorming process itself involves recording ideas suggested at random by participants on
something that everyone can see, such as a flip-chart or whiteboard, to ensure everyone knows what is
going on and encourage full participation. At the end of the time limit, different colored pens are used to
categorize, group, or connect the ideas as necessary to communicate the relationship between them. To
help generate ideas, prompters, such as who, what, where, when, and why, may be used. The ideas
gathered are then combined and refined, creating new headings or lists, where necessary. A skilled
project manager would ensure no ideas are dismissed outright, so that no participants feel their ideas
are unimportant, as feeling this way can have negative effects on motivation and team building. Next, the
ideas or lists created are evaluated, ranked, and developed into a set of actions/options. How the actions
are to be implemented, the appropriate timescale, and who will be responsible are then determined using
other processes or tools. Brainstorming can also be individual if the project is not team based. One of the
ways the outputs from brainstorming can be represented is with a WBS.
TABLE 27.1
Information About the Activities of a Project
FIGURE 27.4 A basic activity-on-node diagram of Table 27.1, showing the critical path in thick arrows and how it is calculated in the box
underneath.
For a more advanced version of the diagram, the node boxes are divided into sections for presenting
more scheduling information, such as the earliest and latest time an activity can start and finish. How this
is done varies widely. Figure 27.5 shows the legend for the example that is used here and Figure 27.6 the
activity-on-node diagram.
Earliest start and finish can be calculated using a technique known as forward pass, which involves the
following:
1. The earliest start (ES) of the first activity in the critical path is 1, while the earliest finish (EF)
of any activity is its ES plus its duration, -1. This means that, for Activity A (the first activity in
the diagram), the ES is 1 and the EF is 1 + 2 - 1 = 2.
2. For the ES of the next activity, 1 is added to the EF of the previous one. This means the ES of
Activity B is 2 + 1 = 3, and the EF is 3 + 3 - 1 = 5.
3. If an activity has more than one predecessor, the one with the latest EF is used, since the next
activity can start only after the latest of the previous ones is completed. So, the ES for Activity F
is 9 + 1 = 10.
Similarly, latest start and finish can be calculated using a technique known as backward pass, which
involves starting from the end of the critical path and working backward, as in the following:
1. The latest finish (LF) of the last activity on the critical path is the same as the EF. To calculate
the latest start (LS), the duration of the activity is subtracted from the LF, and then 1 is added.
This means that the LS of Activity H in the diagram is 19 - 1 + 1 = 19.
2. For the LF of the previous activity, 1 is subtracted from the LS of the next activity, meaning that
the LF of Activity G is 19 -1 = 18, and the LS is 18 - 4 + 1 = 15.
3. After completely filling all the activities in the critical path, those in the next longest path that
have not been filled are filled as described in 1 and 2, and so on, until all activities have been
filled. For example, the next longest path in the diagram is “Start -> A -> B -> D -> F -> G -> H
-> Finish,” and Activity D is the only one that needs to be filled.
CHALLENGE 27.2
If you feel up to it, use the data in the table below to produce an activity-on-node diagram.
Determine also the critical path.
27.3.1.4 Gantt Chart
As should be evident from the example shown of the CPM, a network diagram is not quite intuitive to
read and understand. In contrast, a Gantt chart is easier both to create and to interpret. People do not have
to be trained to be able to understand them. To produce a Gantt chart, a list similar to the one earlier in
Table 27.1 is created that comprises mainly activity ID and name, week number, and duration. The chart
can then be drawn on a simple graph paper or created with dedicated software, into which the data is
entered and the graph generated. A spreadsheet program, such as Microsoft’s Excel, can also be used.
Figure 27.7, which is the Gantt chart version of the network diagram in Figure 27.4, was created using
Excel by simply selecting the number of cells that match an activity’s duration and coloring them.
Activities in the critical path are in black and those not are in grey. No calculations are needed to
determine slack times for activities that are not in the critical path; it is easy to see them. For example,
Activity C has two extra weeks and Activity D, one week, before the next Activity (F) must start. The
arrows linking the end of some activities to the start of others were drawn using normal drawing tools and
indicate that later activities cannot be started until earlier ones have finished. This is known as finish-to-
start (FS) dependency. However, although Gantt charts are easier to create and interpret than network
diagrams, they can be more complex than shown here. They can be more detailed; activities can be broken
down into sub-activities, weeks into days, and various more types of inter-dependencies between
activities and constraints on start and end times can be incorporated. For example, as well as FS
dependency, other types of relationship are possible, such as start-to-start (i.e., an activity can only start
after another activity has started), finish-to-finish (i.e., an activity cannot finish until another has
finished), and complex (i.e., there is more than one relationship between a pair of activities).
FIGURE 27.7 Part of the Gantt chart for the information in Table 27.1.
27.4 Web Project Management Phases
Web projects present similar types of management issues as other types of projects. The same set of
variables, which range from the look and feel of an application to schedule, cost, budget, and resources,
are involved. Some of the most referenced texts on Web project management are those by England and
Finney. In their books, Web project management is described as having four phases: preliminary,
production, final sign-off, and archiving. Other models have described the phases in other ways, such as
in terms of concept development, preproduction, production, testing, and archiving. However,
irrespective of the number of phases, or the labels used, what is important is that the phases of
management span the stages of Web development cycle; after all, Web project management is simply the
management of the various activities of a Web production as well as the associated resources. For the
purpose of discussion, the stages of Web development cycle are defined in this text as initiation,
preproduction, production, and postproduction, and the management phases are matched to these stages
accordingly, as illustrated in Figure 27.8.
27.4.1.2.9 Appendices
Any information that can help the client further understand the proposal, but cannot be included in the
body of the proposal, is placed here. The information might include charts, testimonials, references,
solicitor-checked warrantees and disclaimers, glossary, forms, lists of definitions, acronyms,
illustrations, and short nontechnical description of relevant Web technologies. Again, the amount of
information included depends on factors like the size and complexity of a project. The information is also
usually referred to from the body of the proposal, and relevant proposal page numbers may be used with
relevant information for better cross-referencing. Like the rest of the proposal, the content of appendix
needs to be structured and formatted properly, using sectioning, spacing, and styling appropriately, to
make it easy to scan.
CHALLENGE 27.3
Most Web development contracts contain clauses designed to protect developers from things that
they have no control over. List the things that you think might be out of a developer’s control during a
Web project and therefore need to be addressed in a contract.
CHALLENGE 27.4
Visit http://www.amazon.co.uk and list the roles you would require to build such a site, describing
for what each role will be responsible.
28.1 Introduction
In order for the use of people’s works to be legal, it is generally required by law to first get their
permission. This permission could be for a fee or for free, depending on various factors, such as type of
work, purpose of use, and even country. Intellectual property laws provide information to help determine
in what situations permissions are required and from whom to seek them. Because interactive Web
projects involve the use of multiple media types, some of which can be other people’s works, and some of
which are created in a project, each of which is protected in different ways by law and for varying
durations, it is important for a Web designer to be aware of the different types of laws that govern the use
of other people’s works as well as the protection of those produced in a project.
28.3.1 Copyright
Copyright is the exclusive right to determine what is done with a literary, musical, or artistic work. The
owner of the copyright to a book, for example, has the exclusive right to reproduce, publish, sell, or
distribute it. However, copyright only protects the form of expression of an idea, not the idea itself. The
form of expression, in this case, relates to how elements such as words, musical notes, shapes, colors,
and even inventions are arranged to create a unique piece. So, for example, a person cannot own the
copyright to the idea of making people dance, but can own the copyright to a specific arrangement of
musical notes that they have created to make people dance.
The concept of copyright has its roots in the advent, in the 1430s, of printing technology that made it
possible for the first time to mass-produce and widely distribute literary works. Along with this,
naturally, also came the practices of unauthorized reproduction and distribution of peoples’ literary
works. To control this, the Worshipful Company of Stationers and Newspaper Makers (also known as
the Stationers’ Company) was granted the monopoly of producing and distributing literary works around
1557. The way this worked was that the Stationers’ Company bought manuscripts from authors and, after
the sale, the company decided what to do with the manuscript and kept all profits from it. One of the side-
effects of this practice was that authors had no control over what happened to their works, nor were they
able to benefit financially as much as they should from them. The Copyright Act of 1709 (also known as
the Statute of Anne—named after Queen Anne of Great Britain who passed the act) was designed
primarily to address this seemingly unfair situation and also serve as inducement to authors to produce
more works, knowing that they would profit fairly from them. The act gave the exclusive right of printing
literary works to authors and/or those authorized by them to do so.
This principle was then subsequently extended to other kinds of creative works. Not only this, different
nations around the world came to introduce their own copyright acts, which were sometimes significantly
different from one country to another. The first attempt to establish a framework to internationally
harmonize these various acts was in the form of the Berne Convention for the Protection of Literary and
Artistic Works in 1886. Several copyright conventions and treaties then followed, including the Universal
Copyright Convention (UCC) of 1952, which was created as an alternative for countries that did not like
the terms of the Berne Convention, and the Rome Convention for the Protection of Performers, Producers
of Phonograms and Broadcasting Organizations of 1961. In essence, these conventions and treaties seek
continually to refine and harmonize intellectual property laws, especially is relation to advances in
technology, which often bring about new ways of expressing ideas and creativity, and new modes of
communicating and distributing them.
Under the original Berne Convention, copyright protection extends to all original forms of literary and
artistic works, irrespective of whether they are of good or bad quality. The Convention also lists various
categories of works which member countries, and other countries, should protect under their copyright
laws, most of which can be incorporated in a Web application in one form or another. They include the
following, all of which can be relevant to Web projects, given the presence of the Web in businesses:
Literary works (e.g., poems, theses, lectures, sermons).
Musical works (e.g., musical compositions, including accompanying words).
Dramatic works (e.g., plays, dances).
Sound recordings.
Cinematographic and other audiovisual works.
Radio and television broadcasts.
Artistic works (e.g., paintings, sculptures, drawings, logos).
Lithographic works.
Choreographic works (such as dance routines and ballet).
Photographic works.
Collections of literary and artistic works (such as encyclopedia).
Translations and arrangements of literary and artistic works.
Illustrations, maps, three-dimensional works, and so on.
While the Berne Convention focused on the outputs from the technologies of the time, which were
analogue, subsequent intellectual property treaties extended copyright protection to different types of
digital outputs. For example, the distribution of copyright materials over digital networks, particularly the
Internet, is covered by the WIPO Copyright Treaty (WCT) and the WIPO Performances and
Phonograms Treaty (WPPT), also sometimes referred to as the Internet Treaties. Also covered by
some of these treaties is the copyright protection for the elements of intellectual creativity inherent in the
uniqueness of the design, arrangement, or data selection process in a database. Essentially, database
rights prevent acts like the removal and re-use of whole or substantial part of the contents of a database.
This is without compromising the rights in the individual contents of the database.
Even Web productions are judged to involve creative effort and therefore deserving of copyright
protection. Like for database rights, the rationale is that, although the individual components of a Web
production are themselves creative works and are provided protection under copyright laws, putting them
together in a unique way in a Web production can be regarded as an original form of expression of ideas
and creativity. Some countries, including the UK, also grant a right to copy-protected devices. For
example, a copy-protected device, such as CD, is protected against people copying its content, disabling
the copy-protection mechanism, or making or selling devices, or providing services, to disable it.
Copyright may even apply by virtue of publishing a work, whether in analogue or digital form. For
example, EU Directive 93/98/EEC defines publication right for European Union members and gives
copyright to the person who first publishes a previously unpublished literary, dramatic, musical, artistic,
or cinematographic work after its original copyright has expired. Protection extends to 25 years, starting
from publication.
All in all, the way the unification of rights through conventions and treaties works across countries is
that countries that are signatories to them try to adhere to the framework set out, and the conventions and
treaties, in turn, ensure that there is enough room for individual countries to incorporate their own
additional protection terms.
28.3.2.1 Patents
A patent is a set of rights designed to protect a new and useful invention by protecting features, such as
what the invention does, how it does it, what it is made of, and how it is made. It is granted for only a
period of time, in return for which inventors must disclose the details of their inventions to the public so
that the society can benefit from it, either in its original or improved form. The requirements for granting
patent and the extent of the rights granted vary widely from country to country, depending on national laws
and international treaties. However, there are more similarities than differences.
Generally, in order for an invention to be considered worthy of patent, there must be the element of
newness and human intervention. For example, digging up a substance that no one has ever seen before
from the ground does not qualify as an invention. However, treating it with some chemicals and producing
a new substance can be described as an invention. Some inventions do not necessarily solve any obvious
problems, but are ideas or the representations of ideas. Indeed, according to patent law, an invention does
not have to be in physical form for it to get protection. Consequently, there is more than one type of patent.
The WIPO describes two types: product patent and process patent. A product patent might be, for
example, for a new type of metal, while a process patent might be for a new process of producing a
metal that is not necessarily a new metal. In the case of a website, the product is the website and process
is the new and useful thing the website does. Google homepage design, for example, has a patent. Some
countries describe their types of patent differently. The US, for instance, describes three types: design
(e.g., website design), utility (what website does), and plant patents.
Unlike copyright, patent is not automatic. Patent law requires that an application is submitted to the
patent office, along with a fee, providing the details of the invention and highlighting what is new about it
by comparing it to anything that already exists in the relevant fields. The details must be such that they
allow the production of the invention by others. The invention is then reviewed by qualified people. The
preparation of an application for patent is an undertaking that requires the knowledge of the patent law,
so, legal help is often essential. For an invention to qualify for a patent, it must meet certain set of criteria.
This can be slightly different from country to country. For example, the EU only considers computer
programs that are key to technical processes patentable, whereas in the US, patents can be granted to any
type of computer program. However, in spite of the variations from country to country, the general
requirements are that an invention must
Be novel, that is, it must not have something already known in the relevant field. In order words,
prior art must not exist.
Be producible and of practical use, either to the general public or some industry.
Show an inventive step that is not already known to people in the field.
Be within the scope of subject matter the patent law of a country allows. Typically, it must not be
in such subject matter as scientific or mathematical discovery, theory or method, literary,
dramatic, musical or artistic work, medical treatment or diagnosis, some computer programs,
animal or plant varieties, ways of doing mental acts, playing games or transacting business, or be
anything that is detrimental to public order, morals, or health. This list is, of course, not
exhaustive. Visiting a patent office or its website can usually provide a more detailed list. For
example, information on UK’s patent law is available on the Website of UK Intellectual Property
Office.
Once patent has been granted to an invention, it becomes available to the public, and those who wish to
exploit it commercially can do so, but not without the permission of the patentee (i.e., the patent holder).
Typically, a patentee grants permission to use an invention, that is, licenses it, in return for royalty. This
arrangement enables inventors to profit from their inventions, thereby encouraging more inventions.
Patent protection typically lasts 20 years, but in some countries, there can be additional terms. In the
UK, for example, renewal is required every year after the fifth year for it to last the whole 20 years. Also,
a patent is valid only in the country that granted it and, therefore, to protect an invention elsewhere,
application has to be tendered there, or an international application may be put in under the Patent
Cooperation Treaty (PCT), stating the countries in which patent is required. Application may also be put
in under the European Patent Convention, stating the European countries required. A product can have
multiple patents associated with it, each for a different component. A device like iPhone, for example, has
many patents associated with it, including for the design of components, processes, and interaction
models.
Once a patent expires, the patentee no longer has the rights to prevent people from exploiting the
invention. The rights generally granted by patent law include:
For a product patent, the right to prevent others from reproducing, selling, importing for sale, or
using the product without the permission of the inventor.
For a process patent, the right to prevent others from using, selling, or offering the process for
sale; or importing for the purpose of using, selling, or offering for sale, products produced
directly from the process.
Although these rights are there to be exercised at the discretion of a patentee, there are times when a
patentee’s decision to refuse license to others can be overruled, similar to nonvoluntary license in
copyright. This is known as compulsory license and used by a government when licensing an invention is
in the wider public or government interest. A patented medical invention that could be used to save
people’s lives, for example, is most likely a good candidate for compulsory licensing if the patentee
refuses to grant licenses. Naturally, when a compulsory license is issued, the patentee is also rewarded
adequately. In another kind of patent law exception, the owners of inventions, in certain cases, may not
be legally qualified to patent their inventions. This applies when an invention is made by someone in the
course of doing what they have been employed to do. In such a case, it is usually the employer who will
file for patent and own the patent rights. Of course, an employer may also make a deal to give the inventor
a percentage of royalties.
Note: Page numbers followed by f and t refer to figures and tables, respectively.
#register{} rule, 511
*{} rule, 20
@keyframes at-rule, 569–570
@media rule, 476
!important exception rule, 234, 234f, 242
object-position{} rule, 482–483
:empty pseudo-class, 465–466, 465f, 466f
:default pseudo-class, 561, 561f
:dir(identifier), 450
:invalid pseudo-class, 564, 564f
:not(X) pseudo-class, 464, 464f, 465f
:nth selectors, CSS, 232–233
:out-of-range pseudo-class, 563, 563f
:target pseudo-class, 459–460
lightbox display and, 460–464
::marker (pseudo-element), 456
:valid pseudo-class, 564, 564f
2D animation, 213, 568-579. See also Cascading Style Sheets (CSS), 2D animation
2D animation programs, 217
2D space, 335
3D animation, 213, 580–585
application, 582–584
six degrees of freedom, 580f
3D space, 335
60-30-10 rule, 265–266
A
<abbr> element, 43
“About Us” section, 744
Absolute,
address, 18, 18f
positioning, 356–358
Abstract shapes, 714
Accent color, 266
Accented neutral scheme, 257
Accessibility, websites evaluation for, 809–812
conformance, 810–812, 812f
Accordion menus, 766–767, 766f
A-Checker, 811
action attribute, 92, 93f
Active-state sprite, 507, 509
ActiveXObject, 690
Activity-on-arrow diagram, 832
Activity-on-node network diagram, 832–833, 833f
Adaptive design creation, 680
Adaptive Web Design (AWD),
creation, 680
vs. RWD, 661–663
Additive color method, 252
Additive primary color, 252
<address> element, 49
Advertising, UX, 743
AEB (auto-exposure bracketing), 180
<a> element, 83, 86, 184, 197, 197f
AJAX (Asynchronous JavaScript and XML), 690, 692
alert() function, 114
align-content property,
flex item, 605–607, 605t, 606f
grid item, 642–644, 643f
align-items property,
flex item, 607–610, 607t, 608f, 609f
grid item, 644–645, 645f, 646f
Alignment, visual unity, 737–738, 737f
align-self property
flex item, 610, 611f, 611t, 612
grid item, 647–649, 647f, 648f
Alpha channel, 168, 299
Alpha testing, 801
alt attribute, 119, 142
American Society of Computers, Authors and Publishers (ASCAP), 874
American Standard Code for Information Interchange (ASCII) encoding, 19
Anchor element, 83
Animation 3D, 580–585
component, touch gestures, 787–788
CSS 2D, 568–579
CSS lightbox display, 575–576
@keyframes at-rule, 569–570
multiple animations, 573–574
properties, 570–572, 570t–571t
transitions, 577–579
CSS-only, 588–589
HTML, 213–217, 213f, 214f
2D animation programs, 217
acquiring 2D, 216–217
coding, 217
design, 214–216
effective use, 214–216
stock 2D animation, 216–217
overview, 567–568
in Web design, 585–588
in attracting attention, 585–586
in entertainment, 587
in providing explanation, 587
in providing feedback, 586–587
in providing sequence of items, 588
rollover effect, 586–587
in setting mood, 588
in transition feedback, 586
usage appropriateness, 588
animation-fill-mode property, 573
Anonymous block box, 223
Anonymous flex item, 592
Application structures, website navigation,
hierarchical, 748
linear, 747–748
network, 747–748
Approximate symmetry, 721, 721f
aria-label attribute, 130
Art direction, 151
Aspect ratio, 483
Asymmetrical balance, 721, 722f
Asynchronous JavaScript and XML (AJAX), 690, 692
ATM machine, task analysis of, 795, 795f
Attainable goal, project management, 828
Attributes, 12, 12f
Attribution, right of, 862
Audiences types, 778t–779t
Audio, HTML elements for, 184–196
embedding, 185–190
<audio>, 185–187, 185f, 185t, 186f
<embed>, 188, 188f, 188t
<object>, 189–190, 189f, 189t, 190f
file,
formats, 191, 192t
size, 190–191
linking, 184, 184f
from scratch, 195–196
stock, 194
tracks,
digitization from vinyl records, 195
ripping from discs, 195
Web design, 190–194
acquiring, 194–196
file formats and file size, 190–191, 192t
guidelines on effective use, 193–194
Audio recording, 815
Author-publisher situations, copyright, 864
Auto-exposure bracketing (AEB), 180
Auto-placement algorithm, 619, 628
AWD. See Adaptive Web Design (AWD),
B
backface-visibility property, 346–349
cube example, 347–349
effects of, 347f
background-attachment property, 500, 500f
background-blend-mode property, 526–528, 527f
background-clip property, 492–493, 493f, 493t
Background color, 248
background-image property, 484–485, 485f, 486f, 501
Background images, 175, 484–490
clipping, 492–494
insertion of, 484–487
multiple, 498–500
with background property, 505
position area, 491–492
positioning of, 500–503
repetition, 487–490
repeat-x and repeat-y, 487–489
space and round, 489–490
sizing, 494–498
background-size with keywords, 496–498
background-origin property, 491, 491f, 491t
background-position property, 501, 501f, 502f
background property, 503–506, 504f
multiple background images with, 505
background-repeat property, 487, 487f
background-size property, 494, 495f, 495t, 497f
Backward pass technique, 835
Balance principle, Gestalt effect, 720–723
<b> element, 40–41
Banner blindness, 743
Base64 encoding and data URI scheme, 143, 486
Basic framework, Web development process, 821
<bdi> element/bidirectional isolation element, 58
<bdo> element/bidirectional override element, 58
Berne Convention, 857, 860–861
Beta testing, 801, 843
Bit depth, 167, 190
Bitmap graphics editors, 179
Bitmapped images, 161–168, 161f
color depth, 167–168, 167f
image,
resizing, 163–164, 164f
resolution, 162–164, 162f, 163f
pixels per unit length, 165
PPI,
and displayed image quality, 165, 166f
and printed image quality, 166
Bitrate, 191, 204
Bits per pixel (bpp), 167
Blank-text problem, 700–701
Block-level,
box in CSS, 221
element, 25–26, 34
body{} rule, 320, 496
background-image property, 485–486
Body section, HTML document, 13
contents, 22–28
block-level and inline elements, 25–26
elements and content grouping, 27–29
Body-text typefaces, 399–400, 400f
Boilerplate clauses, 847
border-collapse property, table, 545
border-color property, CSS box, 299–301, 299f, 300t
logical border edges, 300–301, 301f
Border, CSS, 291–313, 304, 304f
border-color, 299–301
border-image, 305–310
border property, 304
border-radius, 310–313
border-style, 291–296
border-top, border-bottom, border-right, border-left, 301–303
border-width, 296–299
border-image property, CSS box, 305–310, 305f, 306f, 309f
longhand, 307t–308t
border-radius property, CSS box, 310–313, 310t, 311f, 312f
generators, 313
longhand, 310
border-spacing property, table, 546–547, 546f
border-style property, CSS box, 291–296, 292t, 293f
logical border edges, 295–296, 296f
longhand, 294–295, 295f
specify multiple values, 293f
border-top/border-bottom/border-right/border-left property, CSS box, 301–303, 302t
logical border edges, 303, 303f
shorthand properties, 302f
border-width property, CSS box, 296–299, 297f, 297t
logical border edges, 298–299, 298f, 299f
Box alignment properties, 602, 640
in grid layout, 641t–642t
Box model, CSS, 222f, 275–334
adding shadows to, 323–325, 323t, 324f
border, 291–313
content hiding, 331–333
dimensions, 275–290
calc(), 289–290, 289f, 290f
min-width/min-height/max-width/max-height, 278–289, 279f
width and height, 276–278, 276f, 277f, 278f
margin, 315–319
outline addition to element, 325–328
padding, 313–315
resizable, 321–322, 321t, 322f
sizes, 319–322, 319t, 320f
Bracketed photos, 180
Brainstorming process, 829–831
Breadcrumb(s),
links, 813
trail, 752, 752f
Breakpoints, 667, 670–671
<br> element, 36–37
Broadcasting organizations’ rights, 866
Browser chrome, 759
Browsing context, 16
Budget section, Web project proposal, 843
<button> element, 52–53, 118–120, 118t–119t, 120f
Button-input type, 114–115, 115f
Button sprites, 508f, 509f
Bytes per pixel (bpp), 167
Cache-Control HTTP, 700
calc() function, 289–290, 289f, 290f
<canvas> element, 154, 154f
Captioning (CC) menu, 201
Captology, 741
Card sorting, 782, 797
Carousels, 767–769, 768f
designing guidelines, 769
Cascading Style Sheets (CSS), 6, 221–245
2D animation, 568–579
CSS lightbox display, 575–577
@keyframes at-rule, 569–570
multiple animations, 573–574
properties, 570–572, 570t–571t
transitions, 577–579, 577t–578t
3D animation, 580–585
in animation, 588–589
at-rule, 476
box model. See Box model, CSS cascading properties, 233–239
inheritance principle, 236–239, 237f, 238f, 239f
last rule principle, 233, 233f
specificity principle, 234–236, 234f, 235f, 236t
color in,
and accessibility, 272–273, 273f
and aesthetics, 267–268
CMYK model, 252
combinations. See Color, combinations in CSS content organization, 266–267
design, 255–273
foreground and background color, 248–251
HSL values, 248
models, anatomy of color, 251–254, 252f
and physiological considerations, 268
preferences, 271–272
proportions, 265–266
and psychological considerations, 269–271, 270t–271t
RGB values, 247–248
specifying, 247–251, 249f, 250f
transparency, 250–251, 251f
values, 254, 254f
YUV model, 252
common attribute selectors, 225t–227t
element transformation in. See Transformation of elements, CSS,
flexible box. See Flexible box layout in image sizing, 473
lightbox display, 575–576
logical properties, 275–276
media query structure, 668f
pixels, 148, 161
preprocessors, 681
advantages, 682
responsive images size using, 477f
rules, anatomy, 223–233, 223f
:nth selectors, 232–233
pseudo-classes, 228, 228f, 229t–232t
pseudo-elements, 227, 228f, 228t
selector types, 225, 225t–227t
rules for layouts, 667–671
breakpoints, 670–671
media queries, 667–670
rules methods, 239–245
<style> element, 241–243, 241f
external, 243–245, 243f, 244f
inline, 239–243
multiple style sheets, 244–245, 244f
style attribute, 240, 240f
transitions, 577–579, 577t–578t
CDNs (Content Delivery Networks), 685
Center alignment, text, 421
Character entity references, 53
Check boxes response format, 818, 818f
Checkbox-input type, 109–110, 110f
Child element, 13, 222
circle() method, 478–479
clear property, 375
Client-server network model, 1
Client-side,
image mapping, 158
JavaScript scripting, 98
scripting, 683–687
embedding, 683–684
external, 684–687
clip-path property, 478, 478t, 479f
Clipping images, 478–480
Closed card sort, 797
Closed questions, 816
Closing tag, 12
Closure, visual unity, 735, 736f
CMYK color model, 252
Codecs parameters, 187, 187t
Codes and database, rights in, 875
Code walkthrough, 803
Cognitive walkthrough, 804–805
<col> elements, 75, 76f, 77f
<colgroup> element, 75
Collapsing text technique, 765, 766f
Collective management organizations, 871
Color,
blindness, 272
circle, 255
combinations in CSS, 255–265, 255f, 256f
analogous scheme, 258–259, 259f
complementary scheme, 260–261, 260f
double contrast scheme, 262–264, 263f
and legibility, 250f
monochromatic scheme, 257–258, 257f
split complementary scheme, 261–262
triadic scheme, 264–265, 264f
depth, 167–168, 167f, 203
display screen, 167
field, 254
picker, 254, 254f
scheme, 255, 257
generators, 257
stop, 511
wheel, 255, 255f
cool and warm colors, 256f
stages, 256f
Color.adobe.com, 257
Colorfulness, 706
Color-input type, 117–118, 117f, 117t, 118f
colspan attribute, 77
column-count/column-rule/column-gap property, multi-column, 385
column-fill property, 386–387
columns and column-span property, 383–384
Compiler, 19
Complementary scheme, color, 260–261, 260f
Compulsory license, 868
Computer code and output, 46–47, 47f, 47t
Container format, 204
Containing element, 13, 222
Content,
alignment, text, 419–427
centering of block of, 424–427
horizontal and vertical centering, 427
horizontal centering, 424, 425f
text-align, 420–421, 420t
vertical-align, 421, 422t, 423f, 424f
vertical centering, 425–426
area, 746
accordion menus, 766–767, 766f
carousels, 767–769, 768f
collapsing text technique, 765, 766f
content amount management, 765–769
content layout, 761–765
content length, 760–761
creation for Web, 770–778
design, 758–778
display size, 758–760
F-shaped pattern, 764–765, 765f
gutenberg rule, 762–763, 762f
homepage content, 758
for international audience, 775
line length, 761
scannable text designing, 770–771, 772f
writing FAQs, 776–778
writing links, 775–776
writing style, 772–774
z-pattern, 763–764, 763f
creation and processing, 851
gathering and clearance process, 849
overflow, 280–288
hyphens, 286–288, 287f, 287t
overflow, 280–281, 280f, 280t, 281f
overflow-wrap, 285–286, 285f, 286f
text-overflow, 283–285, 284f, 284t
white-space, 282–283, 282f, 282t, 283f
Content Delivery Networks (CDNs), 685
content property, text, 453t, 455–456
Continuity, visual unity, 736–737, 736f
Contract and terms page, 843
Contractor-subcontractor situations, copyright, 864
Contrast, emphasis principle through, 723–725, 723f
Controlled testing, 803
Conversational techniques. See Query techniques Cool colors, 256, 256f
Copyright, 856
collectives, 874
IP, 856–866
broadcasting organizations’ rights, 866
duration, 859–860
economic rights, 861
film producers’ rights, 866
free use, 863–864
limitations on rights, 862–865
moral rights, 861–862
non-voluntary license, 864
performers’ rights, 865
phonogram producers’ rights, 865–866
protection, 858–859
related rights, 859, 865–866
rights, 861–862
rights exceptions, 864–865
sui generis database right, 866
out of, 860
symbol (©), 858
The Copyright Act of, 856
Country-specific TLDs, 824
CPM. See Critical path method (CPM),
Craftsmanship, 706
Critical path, 832
Critical path method (CPM), 830, 832–835, 833f, 833t, 834f
Cropping method, 176
CSS. See Cascading Style Sheets (CSS),
Cssmatic.com, 313
Cultural association, 269
Cursive, 399
D
Data,
collection, UCD, 814–820
query technique, 815–820
recording technique, 814–815
technique, 822
compression, 170
Database rights, 857–858
<datalist> element, 125, 125f
Date-input type, 104–105, 104f
Datetime-local-input type, 105, 105f
DAW (Digital Audio Workstation), 195
Decibel (dB), 194
Decimal numeral system, 53–54
Decision symbol, 798
Declaration block, CSS rules, 223
Decorative images, 175, 175f, 176f
Decorative typefaces, 398–399, 399f
Definition lists, 67
Delivering dynamic media, 183–184
Demographic information, 817
Design rights, 869
Detailed framework, Web development process, 821
<details> element, 50–51, 50f
Device-detection script, 680
Device pixel ratios, 148–149, 148f
<dfn> element, 43
Dialog box, 51–52, 52f
<dialog> element, 51, 52f
Diaries technique, 823
Digital Audio Workstation (DAW), 195
Digital camcorder, 212
Digital camera, file size calculation, 173
Digital rights management (DRM), 863
Digital single-lens reflex (DSLR) cameras, 179–180
direction property, text, 436–437, 436f
Direct observation, website development process, 821–822
:dir (identifier), 450
Disclosure, right of, 862
Display,
density descriptors, 149
screen technology, 251
typefaces, 399–400, 400f
Displaying measurement, form, 127–128, 127f, 127t
display property, 366
hiding content by, 331–332
common values, 328t
none value with, 332f
Divine proportion, 729
div#inner{} rule, 498, 500, 505
div#multi{} rule, 498, 505
div{} rule, 320, 492–493, 496
in linear-gradient(, 512
in mix-blend-mode property, 529
DNS (Domain Name System), 5
Document,
embedding, 159–161, 159t, 160f
type declaration, 13
Document object model (DOM), 12
Domain name, 2
registration, 823–824
with Web server, 824
Domain Name System (DNS), 5
Dominant color, 265–266
Dot, 707–708, 707f
convention, 129
Dots per inch (dpi), 166
Double-contrast scheme, 262–264, 263f
Dreamweaver, 6
DRM (digital rights management), 863
Drop-down list,
<datalist>, 125, 125f
<select>, 122–124, 123f, 123t, 124f
Drop-down menus, 52–53, 754–755, 755f
Dynamic media, 183
Dynamic websites, 6
E
Economic rights, 861
Element positioning in drop-down menus, 366–370
using <button> element, 369–370
using list elements, 366–369
Embedded resolution, 165
<em> element, 40
Emphasis principle, Gestalt effect, 723–727
contrast, 723–725, 723f
isolation, 725
placement, 726–727
Employer-employee situations, Web development process, 864
Enhanced CSS, 681–682
repetition of declarations, 682f
Escape characters/codes, 53
EU Directive 93/98/EEC, 858
EU Directive 96/9/EC, 866
European Patent Convention, 868
Evaluation,
phase, UDC, 801–809
usability testing, 801–809
section, Web project proposal, 842–843
Exceptions, 862–863
Executive summary, 841
Explicit grid tracks, 626
External CSS, 239, 243–245
HTML document, 243f
F
Fair dealing, 863
Fallback content, 185, 198
Family of fonts, 390
Fantasy typefaces, 399
<figcaption> element, 146
File-input type, 115–117, 116f, 116t
Film producers’ rights, 866
Final sign-off, 852
Finish-to-start (FS) dependency, 836
Fitts’ law, 786, 809, 809f
Fixed layouts, 659
Fixed positioning, 358–361
application, 359–361
Fixed width layouts, 659
Flash of Invisible Text (FOIT), 700–701
Flash of unstyled content (FOUC), 700–701
Flash technology, 213
Flatbed scanners, 180
Flexbox. See Cascading Style Sheets (CSS), flexible box Flex container, 592
block-level/inline-level, 593
flex item alignment in, 602–612
align-content, 605–607, 605t, 606f
align-items, 607–608, 607t, 608f, 609f
justify-content, 602–604, 603f, 603t, 604f
multi-line, 592–593
single-line, 592
flex-direction property, 593, 594f, 594t
Flexible box layout, 591–593, 592f
anonymous flex item, 592
flex container, 592
block-level/inline-level, 593
flex-direction and flex-wrap property, 597
flex items, 592
alignment, 602–612
control of flow direction, 593–595
ordering, 612–613
size of, 597–602
flex line, 592
wrapping of, 595–596
flex property, 599t
in vertical space allocation, 600, 601f
guidelines for using, 614
longhand flex properties, 598t
Flex items, 592
alignment, 602–612
in flex container, 602–609
individually, 610–612
control of flow direction, 593–595
ordering, 612–613
size of, 597–602
factors, 597, 598t
flex shorthand property, 598–602
Flex line, 592
wrapping of, 595–596
flex shorthand property, 598, 602
flex-wrap property, 595, 595t, 596f
Floated elements, 375–381
multi-column content with floats, 380–381
non-floated parent elements, common problem with, 379–380
Floating elements, 372–375
float property, 352, 372, 373f, 380
Float/slack time, 833–834
Fluid mobile layout, 672f
HTML and CSS code, 673f
Focus group, 817
FOIT (Flash of Invisible Text), 700–701
Fold, 761
Font(s), 390. See also Text
in design (typeface of), 397–406
body-text typefaces, 399–400, 400f
classifications, 397–398
decorative typefaces, 399, 399f
display typefaces, 399–400, 400f
monospaced typefaces, 400–401, 401f
proportional typefaces, 400–401, 401f
script typefaces, 399, 399f
serif and sans serif, 398–399, 398f
serif typefaces, 398–399, 398f
typeface selection. See Typeface(s), selection of family, 390
properties,
font-feature-settings, 415
font-stretch, 417
font-synthesis, 416
font-variant, 416–417, 416f
multiple, 417–418
specialized, 415–417
size of text, 409–411
operating systems, resolution, and screen size, 409–410
target audience and type size, 410
and typeface, 409
visual hierarchy and type size, 410–411
stack, 390
@font-face property, 392–396
broad browser support, 394–396
font-family property, 390–392, 391f, 391t
font-feature-settings property, 415
Font-hosting service, 396
font-size-adjust property, 408–409, 409f
font-size property, 406–408, 406t, 407t
font-stretch property, 417
font-synthesis property, 416
font-variant property, 416–417, 416f
font-weight property, 411–413, 412f
Footer, Web page, 746
Foreground color, 248
<form> element, 92, 93t–94t
Form(s), 91–137, 552–565
controls, 92, 94–135, 95t
<input>, 94–118
displaying measurement, 127–128, 127f, 127t
drop-down list, 122–125
grouping, 132–133, 132t, 133f
labeling, 129–132
multiple lines text input, 120–122, 121t, 122f
multipurpose button, 118–120, 118t–119t, 119f
outputting calculation result, 128–129, 128f, 128t, 129f
showing task progress, 126, 126f
cursor,
property, 562, 562f, 563f
shape, 562, 563f
design guidelines, 136
element, 91–94, 92f, 93t–94t
images in input fields, 555–557
inputs validation, 563–565
:in-range and :out-of-range, 563–564
:valid and :invalid, 564–565
styling of form elements, 557–562
buttons, 559–560
default button, 561
:default pseudo-class, 561, 561f
pseudo-classes for, 557, 557t, 558f, 559
validation, 98
Formal balance, 721
Formative evaluation, 801
Forward pass technique, 834
FOUC (Flash of unstyled content), 700–701
Frames, 203, 567
rate, 203
size, 203
Free use, copyright, 863–864
F-shaped pattern, 764–765, 765f
FTP program, 824–825
Functional image, 146
Functional requirements, 796
G
Gantt chart, 830, 836, 836f
General-purpose coding languages, 217
Geometric objects/primitives, 168
Geometric shapes, 714
Gestalt effect, 706–707
design principles, 720–738
balance, 720–723
emphasis, 723–727
proportion, 728–732
rhythm, 727–728
unity, 732–738
Gestalt theory, 706, 720
GET method, 92–93
GIF, 171
Animators, 217
format, 213
Global attribute, 13, 81, 143
Global event attribute, 684
Goals and objective section, Web project proposal, 841
Goals, Operators, Methods, Selection (GOMS) rules, 807
Golden ratio, 729–731
Golden spiral, 730, 731f
Golden triangle area, 765
Google Webmaster Tools, 813
Gradient line, 512
Gradient Mesh tool, 169
Gradients, images, 511–523
linear, 512–517
linear-gradient() function, 512, 513t
repeating, 515–516
repeating-linear-gradient() function, 515–516, 515f
radial, 517–523
application, 520, 521f
repeating, 522, 523f
repeating-radial-gradient()
function, 522, 523f, 524f
radial-gradient() function, 517, 518t, 520
tool, 512f
Graphics editors, 179
Grid,
application of, 653–654
container, 616
block-level/inline-level, 617
grid item alignment in, 640–649
explicit grid properties, 631
gutter properties, 631
implicit properties, 631
item(s), 617
alignment, 640–649
display sequence, 649–650
justify-content and align-content, 642–644
justify-items and align-items, 644–645, 645f, 646f
justify-self and align-self, 647–648
layer positions for stacked, 651–652
ordering, 649–652
order property, 649, 650f
placement within grid, 633–639
z-index property, 651–652, 651f
layout. See Layout grids lines, 616
multiple names for, 621
property, 631, 632t–633t
track, 616
size, 618, 619t
grid-area property, 638–639, 639t
grid-auto-columns property, 626–627, 626f
grid-auto-flow property, 628–629, 628t, 629f
grid-auto-rows property, 626–627, 626f
grid-gap property, 630–631
Grid-placement property, 633, 634t
grid-area, 638–639, 639t
grid-column and grid-row, 637–638
grid-template-areas property, 622–623, 622f
grid-template-columns property, 618–619, 620f
grid-template property, 624, 624t–625t
grid-template-rows property, 618–619, 620f
Grouping, 706
<fieldset>/<legend>, 132–133, 133f, 133t
elements and content, 27–28
Group interview, 815, 817
Gutenberg rule, 762–763, 762f
Gutter, 382
GYM rating, 772
H
H.265, 204
profile-level-tier concept in, 207t
Hallway testing, 802
Halo Effect, 741
Hand-held scanners, 180
Hanging indent, 428
Hard wrap, 280
Harmonious designs, 705–706
HDMI (High-Definition Multimedia Interface), 212
Header, 746
section, HTML document, 13
headers attribute, 81–83
Headings, text, 32–34, 32f
design, 33–34, 33f, 34f
Head section, HTML document, 14–22
<base>, 16–17, 16f
<link>, 17–19, 17t–18t, 18f
<meta>, 19–22, 20f, 20t, 21f
<title>, 15–16, 15f
Heuristic evaluation, 805–807
Hexadecimal numeral system, 53–54
Hex codes, 247–248
Hiding content, 331–333
by display property, 331–332
by visibility property, 332–333
Hierarchical navigation structure, 748f
Hierarchical structure, 747–748
Hierarchical Task Analysis (HTA), 794–795, 795f
High-Definition Multimedia Interface (HDMI), 212
High-dynamic-range (HDR) images, 180
High-fidelity prototypes, 797
High-key colors, 718
High-value colors, 718
Horizontal and vertical centering, text, 427, 427f
Horizontal centering, text, 424, 425f
Hover effect, 586–587
Hover state, 786–787, 507
Hover-state sprite, 508
<hr> element, 36
href attribute, 16, 16f, 86–87
HSL. See Hue, saturation, and lightness (HSL),
HTA. See Hierarchical Task Analysis (HTA),
HTML. See HyperText Markup Language (HTML) HTML5 layout elements, 23t–24t, 24f
HTML5 Video Caption Maker, 201
HTML, text, 31–66
authors’ details and publication dates, 49–50, 49f, 50f
definitions and abbreviations, 43–44, 43f, 44f
displaying,
computer code and output, 46–47, 47f, 47t
dialog box, 51–52, 52f
preformatted text, 48–49, 48f
special characters, 53–56, 54f, 54t, 55f
edit, 45–46, 45t, 46f
headings, 32–34, 32f
design, 33–34, 33f, 34f
hidden additional information, 50–51, 50f, 51f
importance, emphasis, and relevance, 40–41, 40f, 41f
language information and text directionality, 56–60
dir, 58–60, 59f
lang, 56–57, 57f
line breaks, thematic breaks, and comments, 36–38, 37f
word-break opportunities, 37–38, 38f
menu bar and drop-down menus, 52–53, 53f
paragraphs, 34–36, 35f
design, 35–36, 36f
quotations and citations, 42–43, 42f, 42t, 43f
ruby text, 60–65, 61f, 61t
<rbc> and <rtc>, 64–65, 64f, 65f
<ruby>, <rb>, <rt>, and <rp>, 62–64, 62f, 63f
small, 44–45, 44f, 45f
superscript and subscript, 39, 39f
usage for Web design, 65–66
HTTP (HyperText Transfer Protocol), 3
HTTP headers, 93
Hue and value, visual aesthetics design, 718–719, 719f, 720f
Hue, saturation, and lightness (HSL), 253
color model, 253, 253f
values, 248
Hyperlinking, 183
Hyperlinks, 2, 83
Hypermedia system, 2, 3f
Hypertext, 2
HyperText Markup Language (HTML), 6, 11–30, 661
creating Web page, 29–30
with text editor, 29–30
document, structure, 13–28, 14f
block-level and inline elements, 25–26, 26f
body section, contents, 22–25, 23f, 25f
grouping elements and content, 27–28, 27f
head section, contents, 14–22
elements, 13, 14t
overview, 11
structure, 12f, 13–28
text. See HTML, text versions, 28
WYSIWYG, 29
HyperText Transfer Protocol (HTTP), 3
hyphens property, 286–288, 287f, 287t
I
IANA Language Subtag Registry, 56
IAR (image aspect ratio), 163
id attribute, 13, 86–87, 86f, 87f
and accessibility, 81–83, 82f
<i> element, 40–41
<iframe> element, 159, 159t, 160f, 161
Illusion of depth, 718f
Image(s), 139–182
acquisition for use, 179–181
graphics editors, 179
photography, 179–180
scanning, 180
stock, 179
Web coding languages, 180–181
aligning, 480–481
background, 484–490
clipping, 492–494
insertion of, 484–487
multiple, 498–500
position area, 491–492
positioning of, 500–503
repetition, 487–490
sizing, 494–498
blending, 526–530
background-blend-mode property, 526–528, 527f
isolation property, 529–530, 529f
mix-blend-mode property, 528–529, 528f
modes, 526f
multiple blending modes, 527f
plain color effect, 526
breakpoints, 150
clipping, 478–480
cropping, 163
document embedding, 159–161, 159t, 160f
effective use, guidelines for, 174–178
and captions, 177–178
decorative, 175–176
large, 176
with text, 176–177
effects, 507–531
filters, 523–525
definition, 523
filter property, 523–525, 524t, 525f
gradients, 511–523
linear, 512–516
radial, 517–523
tool, 512f
with HTML,
<canvas>, 154, 154f
<svg>, 154–155, 154f, 155f
<img>, <source>, and <picture>, 140–153, 140t–141t
<map> and <area>, 155–158, 155t, 156f, 157f
interpolation, 162
mapping, 155, 155t
and photographs, rights in, 872–873
positioning and fitting in element’s box, 481–484
object-fit property, 483, 483f, 484f
object-position property, 482–483, 482f
scanning, 180
sizing, 473–478
multiple images, 474
resized image quality, 475–476
responsive images, size, 476–478
width and height property, 474f
sprite, 507–511
active-state sprite, 509
advantage, 507
button sprites, 508f, 509f
definition, 507
with <input> element, 510–511
hover-state sprite, 508
with image-input type, 510f
normal-state sprite, 508
with text, 176–177, 177f
types, 161–174
bitmapped. See Bitmapped images digital camera, calculating file size,
generated, 173
file formats and size, 170–172, 171t, 172f
file size calculation, 173
file transmission time, 174
vector, 154, 168–170, 168f, 169f, 170f
Image aspect ratio (IAR), 163
Image-based assets, 699–700
Image-input type, 113–114, 113f, 113t, 510
image-rendering property, 475, 475f, 475t, 476f
<img> element, 213
img{} rule, 482
Implicit grid tracks, 626
In-betweening process, 567
Indent, 428
Indirect observation, 822–823
Industrial property, IP, 856, 866–870
industrial designs, 869
patents, 867–869
trademarks, 870
Web design, 875
Infinite scrolling technique, 760
Informal balance, 721
Information,
foraging theory, 761
scent theory, 761
Inheritance principle, CSS, 236–239, 237f, 239f
HTML, 238f
<input> element/types, 94–118
for action initiation, 110–118
button-input, 114–115, 115f
color-input, 117–118, 117f, 117t, 118f
file-input, 115–117, 116f, 116t
image-input, 113–114, 113f, 113t
submit-input and reset-input, 111–112, 111t, 112f
numbers collection, 100–103, 100t
number-input, 100–101, 100f
range-input, 101–103, 101f, 102f, 103f
for offering options, 108–110, 108t
checkbox-input, 109–110, 110f
radio-input, 108–109, 108f, 109f
plain text collection, 95–99, 96t–97t, 98f, 99f
text collection, 95
time and date collection, 103–107
date-input, 104–105, 104f
datetime-local-input, 105, 105f
month-input, 106, 106f
time-input, 103–104, 103f, 104f
week-input, 107, 107f
Initiation phase, Web project management, 837–844
appendices, 844
budget section, 843
evaluation section, 842–843
goals and objective section, 841
introduction section, 841
methodology section, 842
needs section, 841
project definition process, 838
proposal process, 838–839, 840f
qualifications section, 843–844
summary section, 841
Inline CSS, 239–243
style attribute, 240, 240f
<style> element, 241–243
Inline elements, 328–330, 328t, 329f
Inline-level type box, CSS, 221
in-range pseudo-class, 563, 563f
Insert, delete, and strikethrough elements, 45t, 46f
Integrity, right of, 862
Intellectual property (IP), 855–872
copyright, 856–866
industrial property, 866–870
infringement, 871–872
seeking permission, 870–871
useful info, 876
Web design, 872–875
Interaction logging technique, 801–802, 823
Intermittent sign-off, 852
Internet and Web, 1–7
fundamentals, 1–4
overview, 1
websites creation, 6
working, 5, 5f
Internet Protocol (IP), 2
Internet service providers (ISPs), 2, 823
Internet Treaties, 857
Interviews, query techniques, 815–817, 816f
Intra-frame-only compression, 210
:invalid pseudo-class, 564, 564f
IP. See Intellectual property (IP),
IP (Internet Protocol), 2
IP address, 2, 5
IPv4, 2
IPv6, 2
isolation property, blending images, 529–530, 529f
ISPs (Internet service providers), 2, 823
J
JavaScript, 6, 13, 15, 588–589
embedding, 683f, 684f
libraries, 685
JPEG, 171
jQuery library, 685
Justification, text, 421
justify-content property, 642–644, 643f
flex item, 602–604, 603f, 603t, 604t
justify-items property, 644–645, 645f, 646f
justify-self property, 647–648, 647f, 648f
Keyboard events attributes, 13
Keyframes, 567
Keystroke-Level Model (KLM) method, 807–809
Keyword stuffing, 142, 331
KLM-GOMS, 807
L
<label> element, 129–130, 129t, 130f, 131f
Label reference technique, 129–130
Language,
code, 56
information and text directionality, 56–60
dir, 58–60, 59f
lang, 56–57, 57f
Last rule principle, CSS, 233, 233f
Layout grids,
alignment, 640–649
creation properties, 617–640
columns, rows, and areas, 618–625
gutters between grid columns and rows, 630–631
implicit tracks and items’ auto-placement,, 626–629
item placement within grid, 633–639
structure properties, 631–633
grid-auto-columns and grid-auto-rows, 626–627, 626f
grid-auto-flow, 628–629, 628t, 629f
grid item alignment,
in grid container, 640–646
individually, 647–648
grid item ordering, 649–652
grid-template, 624, 624t–625t
grid-template-areas, 622–623, 622f
grid-template-columns and grid-template-rows, 618–619, 619t, 620f
model, anatomy of, 616, 616f
overview, 615–616
track size value, 619t
Lazy loading of fonts, 700–701
Leading, text. See Line, spacing,
Left alignment, text, 421
Legibility, typefaces, 401–402
Licensing agencies, 874
Lightbox display,
animated, 464
CSS, 575–577
with: target pseudo-class, 460–464
Likert scales, 819, 819f
Line,
breaks, thematic breaks, and comments, 36–38, 37f
height, 433–434
spacing, 432–434
visual aesthetics design, 708–713
linear-gradient() function, 512, 513f, 513t
Linear gradients, images, 512–516
repeating, 515–516
Linear navigation structure, 798
Link(s), 83–90, 83f
to another page on same website, 85–86, 85f
to another part on same page, 86–89
id attribute, 86–87, 86f, 87f
name attribute, 87–88, 88f
within-page links in Web design, 88–89
to another website, 84–85, 84f
to e-mail program, 89–90, 90f
to specific part on another page, 89
title, 776
Liquid layouts, 659–660
Lists, 533–542
element conversion to list-items, 541–542, 542f
HTML, 67–72, 68f, 69f
common attributes, 69–71
nested lists, 71–72, 71f, 72f
property,
list-style, 537, 537f, 538f
list-style-image, 535, 535f, 536f
list-style-position, 536, 536f, 537f
list-style-type, 533–535, 534f, 534t
styling using generic properties, 538–541
<ol> and <ul> elements, 538–540
definition lists, 540–541, 541f
HTML, 539f
list-style-image property, 535, 535f, 536f
list-style-position property, 536, 536f, 537f
list-style property, 537, 537f, 538f
list-style-type property, 71, 533–535, 534f, 534t
Logical offset properties, 355
Logical operator, 667
Longhand flex properties, 598t
Longhand formats, 290–291
border-image, 307t–308t
border-style, 294–295, 295f
Lossless compression, 170
Lossy compression, 170–171
Low-fidelity prototypes, 797
Low-key colors, 718
Low-value colors, 718
M
Maintenance plan, 842
MakeMKV program, 211
margin property, 315–319
in design, 318–319, 319f
effects, 319f
for logical edges, 317–318
longhand properties, 315
<mark> element, 40
Master recording license, 874
Measurable goal, project management, 828
Media,
conditions, 140
events attributes, 13
objects design process, 850
production tools selection, 850–851
queries, 667–670
CSS, structure of, 668f
operators, 667
prefix, 667
style rules, 669
types and features in RWD, 669t
Mega drop-down menu, 749, 755, 755f
Megapixels, 162
Menu bar menus, 52–53, 53f
<menu> element, 52, 53f
<menuitem> element, 52–53, 53f
Metadata, 14
<meter> element, 127, 127f, 127t
method attribute, 92, 93f
Methodology section, Web project proposal, 842
Microdata markup, 813
MIME type, 683–684
Minification, 698–699
Minifiers, 699
min-width and min-height and max-width and max-height property, 278–289, 279f
content overflow, 280–288
hyphens, 286–288
overflow, 280–281
overflow-wrap, 285–286
text-overflow, 283–285
white-space, 282–283
minimum and maximum logical width and height, 288–289, 288f
Miro Video Converter, 201
mix-blend-mode property, 528–529, 528f
Mobile design pattern, 784
Mobile devices, 781–790
smartphones, design of, 781–788
content, 782–784
navigation, 784–788
tablets, design of, 789–790
Mobile first technique, 663
Monochromatic scheme, 257–258, 257f
Monospaced font, 46
Monospaced typefaces, 400–401, 401f
Month-input type, 106, 106f
Moral rights, 861–862
Morse code, 19
Morton, Jill, 269
Morville, Peter, 740
Motion tweening, 567–568, 568f
Mouse events attributes, 13
Multi-column layout, 381–387
column-count, column-rule, and column-gap, 385
column-fill, 386–387
columns and column-span, 383–384
multiple attribute, 115
Multiple background images, 498–500
with background property, 505
Multiple image sources, 148–153
device pixel ratios, 148–149
image contents, 151–152
and device pixel ratios, 152–153
image file formats, 153
viewport sizes, 149–150
using media condition, 150–151
Multiple style sheets, CSS, 244–245, 244f
Multipurpose button, 118–120, 118t–119t, 120f
Music and speech, rights in, 873–874
N
name attribute, 87–88, 88f
Name server, 5
Natural association, 269
Natural shapes, 714
Navbar, 754
Navicon, 664
Navigation,
designing for smartphones, 784–788
touch gestures and animations, 787–788
touch targets, 786–787
elements, 748–752
links to sections, 749–750
search facility, 750, 751f
utilities options, 750
website ID, 749
“You are here” indicator, 751–752
permanent design, 749f
persistent, 747
structure, hierarchical levels, 748f
Needs section, Web project proposal, 841
Negation CSS pseudo-class. See :not(X) pseudo-class,
Negative space, 716
Nelson, Ted, 2
Nested lists, 71–72, 71f, 72f
Network(s),
navigation structure, 798
structure, 747–748
types, 1
Network Solutions, 824
Neutral scheme, 257
Nielsen, Jakob, 176
Nielsen Norman Group (NN/g), 215, 742–743, 770, 806
Non-breaking spaces, 55–56
Non-disclosure agreement, 841, 846
Nonvoluntary license, 864
Normal-resolution images, copyright, 153
Normal-state sprite, 508–509
Nielsen Norman Group, 803
:not(X) pseudo-class, 464, 464f, 465f
Number-input type, 100–101, 100f
Numeric character references, 53
O
object-fit property, 483, 484f
object-position property, 482–483
Observational techniques, 820–823
direct observation, 821–822
indirect observation, 822–823
offset-block-start property, 355
Offset for logical edges, 355–356
offset-inline-end property, 355
offset-inline-start property, 355
onclick event attribute, 114
opacity property, 248
Open card sort, 797
open() method parameters, 692
Open question, 816
Optical Character Recognition (OCR) program, 65
Ordered lists, 67
order property, grid item, 649, 650f
Outdent, 35, 428
outline-offset property, 327, 327f
outline property, 325–328, 325t, 326f
<output> element, 128–129, 128f, 128t, 129f
overflow property, 280–281, 280f, 280t, 281f
overflow-wrap property, 285–286, 285f, 286f
Overlapping elements, 370–372
P
Padding, 221
property, 313–315, 313t, 314f
for logical edges, 314–315, 315f
Paletton.com, 257
Paper prototype, 800, 800f
testing, 803
Paragraph-level thematic break, 36
Paragraphs, text, 34–36, 35f
design, 35–36, 36f
Parent element, 13, 222
parent{} rule, 320
Participant observation, 821
Participant-observer, 821
Passive observation, 821
Patent(s), 867–869
law exception, 868
types, 867
Patent Cooperation Treaty (PCT), 868
Payment schedule page, 843, 845
PCT (Patent Cooperation Treaty), 868
PDM (precedence diagram method), 832
Peer-to-peer network model, 1–2
<p> element, 34
Performance license, 873
Performers’ rights, 865
Persistent navigation, 747
perspective() function, 340–341
perspective property, 341–345
application, 343–345
Persuasive technologies, 741
Persuasive Web design, 741
PERT (Project Evaluation and Review Technique) chart, 832
Phi, 729
grid, 615, 730
Phonogram,
producers’ rights, 865–866
right, 859
Photic stimulation, 268
Photography, 179–180
Photomontage, 863
Pixel(s), 148, 161, 167, 658
density, 165, 658
depth, 167
dimensions, 162, 658
Pixel per unit length, 165
Pixels per centimeters (ppcm), 165
Pixels per inch (PPI), 165, 658
and displayed image quality, 165–166, 166f
and printed image quality, 166
Plagiarism, 872
Plug-in, 4
Pluralistic walkthrough, 804–805
PNG, 171
Point-and-shoot cameras, 179
Point, visual aesthetics design, 707–708, 707f
Pop-up menu, 754
Positioning elements,
CSS positioning methods, 351–352
absolute, 356–358
clearing obstructed floated elements, 375–381
element positioning in drop-down menus, 366–370
fixed, 358–361
floating elements, 372–375
ordering overlapping elements, 370–372
relative, 353–356
static, 352–353
sticky, 361–366
multi-column layout, 381–387
column-count, column-rule, and column-gap, 385
column-fill, 386–387
columns and column-span, 383–384
Positioning methods, CSS, 351–352
absolute, 356–358
in drop-down menus, 366–370
using list elements, 366–369
using <button> element, 369–370
fixed, 358–361
application, 359–361
floating elements, 372–375
obstructed floated elements, 375–381
multi-column content with floats, 380–381
non-floated parent elements problem, 379–380
ordering overlapping elements, 370–372
relative, 353–356
offset for logical edges, 355–356
static, 352–353
sticky, 361–366
global navigation, 363–366
Positive space, 716
Posterization effect, 167
POST method, 93
Postproduction phase, Web project proposal, 851–852
closure, 852
delivery and final sign-off, 852
final evaluation, 851–852
PPI. See Pixels per inch (PPI),
Pragma directive, 19
Precedence diagram method (PDM), 832
Predictive modeling methods, 807
Preformatted text, 48–49, 48f
Preproduction phase, Web project proposal, 848–851
content gathering and clearance process, 849
media,
objects design process, 850
production tools selection, 850–851
project team selection, 848
website design process, 849–850
preserve-3d values, 345–346
Primary code, 56
Primary color, 255
psychological, 256
Process patent, 867–868
Production phase, Web project proposal, 851
Product patent, 867–868
<progress> element, 126, 126f
Progressive,
disclosure, 765, 783, 783f
enhancement, 661
Project,
review, 852
scope of Web project management, 838
Project Evaluation and Review Technique (PERT) chart, 832
Property inheritance, 237f
Proportional typefaces, 400–401, 401f
Proportion principle, Gestalt effect, 728–732
golden ratio, 729–731
rule of thirds, 731–732
Proposal process, Web project management, 838–840, 840f
Prototypes, 797
high-fidelity, 797
low-fidelity, 797
paper, 800
Proximity, visual unity, 732–733
Pseudo-classes,
CSS, 228, 228f, 229t–232t
text styling with, 457–466
:empty, 465–466, 465f, 466f
lightbox display and,
target, 460–464
links, 457, 457t, 458f
:not(X), 464, 464f, 465f
:target, 459–460
Pseudo-elements, 452, 453t
CSS, 227, 228f, 228t
text styling with, 452–457
content property, 455–456
::first-letter, ::first-line, ::before, ::after, ::selection, 454–455
Psychological association, 269
Psychological primary colors, 256
Publication right, 858
Pull-down menu, 754
Pure symmetry, 721, 721f
Q
Qualifications section, Web project proposal, 843–844
Query techniques, 802, 815–820
interviews, 815–817, 816f
questionnaires, 817–820, 818f, 819f, 820f
Questionnaire for user interface satisfaction (QUIS), 820
Quotations and citations, 42–43, 42f, 42t, 43f
QWERTY keyboard, 784
R
Radial balance, 722, 722f
radial-gradient() function, 517, 518t, 519f, 520
Radial gradients, images, 517–523
application, 520, 521f
repeating, 522, 523f
Radio buttons, 818, 819f
Radio-input type, 108–109, 108f, 109f
Range-input type, 101–103, 101f, 102f, 103f
disadvantage, 101
Range response format, 818, 818f
Ranking method, 818–819, 819f
Raster images, 161
Rating scale, 819–820, 819f, 820f
Reading gravity, 762
Recitals, 845
Red, green, and blue (RGB),
color, 252, 252f
model, 252
values, 247–248
Refuse attribution, right of, 862
Regex (regular expression), 99
Registered trademark symbol (®), 870
Regular expression (regex), 99
Relative address, project management, 18, 18f
Relative positioning, 353–356
offset for logical edges, 355–356
Relevance-enhanced image reduction, 176
Relevant goal, 828
repeating-linear-gradient() function, 515–516, 515f
repeating-radial-gradient() function, 522, 523f, 524f
repeat-x value, background image, 487, 488f
repeat-y value, backgorund image, 489, 489f
Repetition, visual unity, 735, 735f
Requirements-gathering phase, UDC, 796
Requirements statement, 796
Reset-input types, 111–112, 111t, 112f
Resolution switching, 148
Response formats, 818
Responsive images, 140
resolutions, 478
size, 476–477
Responsivepx, 671
Responsive Web Design (RWD), 410, 657–680, 664f
implemenation,
via flexbox, 672–677
via grid, 677–679
steps for creation, 666–671
CSS rules for layouts, 667–671
fluid media assets, 666–667
layouts for screen sizes, 666
vs. AWD, 661–663
RetrieveRecords.php, 696
RGB. See Red, green, and blue (RGB),
Rhythm, visual aesthetics design, 727–728, 728f
Ribbon design approach, 755
Right alignment, text, 421
Rollover effect, 507, 586–587
Rome Convention, 857, 865
Rotation and skewing functions, 338–340
Royalties, 864
ruby-align property, 468, 468f, 468t
Ruby base text, 60
ruby-merge property, 469–470, 470t
ruby-position property, 467, 467t, 468f
Ruby properties, text, 466–471
elements conversion to ruby elements, 470–471
ruby display values, 470t, 471f
for styling and formatting, 466–470
ruby-align, 468, 468f, 468t
ruby-merge, 469–470, 470t
ruby-position, 467, 467t, 468f
ruby text, 60–65, 61f, 61t
<rbc> and <rtc>, 64–65, 64f, 65f
<ruby>, <rb>, <rt>, and <rp>, 62–64, 62f, 63f
Rule of thirds, 731–732
Rules of thumb, 805–806
RWD. See Responsive Web Design (RWD),
S
Sampling,
rate, 190
resolution, 190
Sans serif typefaces, 398–399, 398f
SASS (Syntactically Awesome Style Sheets), 681
Sassy CSS (SCSS), 681
Scalable Vector Graphics (SVG), 140, 154, 169, 213
Scaling method, 176
Scannable text, 770–771
Scanned documents, image file size calculation, 173
Scheduling charts, 831
scope attribute and accessibility, 80–81, 80t, 81f
scoped attribute, 242–243, 242f, 243f
Scoping process, 838
Screen,
reader, 4
resolution, 658–659
size, 657–658
Screencast, 212
Scripting languages with HTML, 683–697
client-side scripting, 683–687
embedding, 683–684
external, 684–687
server-side scripting, 687–697
with AJAX, 690–692
data storage in databas, 692–695
retrieving of data from database, 695–697
script, AJAX, and Database, 692
<script> element, 15
Scripts, 399, 684
Script typefaces, 398–399, 399f
Scrolling, smartphones, 782
SCSS (Sassy CSS), 681
SDI (Serial Digital Interface), 212
SDLC (software development life cycle), 793
Search engine optimization (SEO), 15, 663, 772
websites evaluation for, 812–814
Search engine results pages (SERPs), 663, 812
Secondary color, 255
Secure Sockets Layer (SSL), 744, 824
See-saw analogy, 720
<select> element, 122, 123f, 123t, 124f
Selector block, CSS rule, 223
Semantic differential scales, 819, 820f
Semantic meaning, 22
Semi-structured interviews, 815–816
SEO. See Search engine optimization (SEO),
Serial Digital Interface (SDI), 212
Serif typefaces, 398–399, 398f
SERPs (search engine results pages), 663, 812
Server-side image mapping, 158
Server-side scripting, 687–697
with AJAX, 690–692
data storage in databas, 692–695
retrieving of data from database, 695–697
script, AJAX, and database, 692
Service mark, 870
Shade of color, 253, 253f
Shapes, visual aesthetics design, 714–715, 714f
Shape tweening, 568, 568f
Shorthand,
animation property, 570
background property, 503–506
border-color property, 300t
border-style property, 294t
border-width property, 297t
formats, 290–291
transition property, 577
Similarity, visual unity, 733–735
Simplicity factor, visual aesthetics design, 706
Site map, 755–757, 756f, 798
Six degrees of freedom, 580
Size of text, 406–411
font-size, 406–408
font-size-adjust, 408–409
font size in design, 409–411
operating systems, resolution, and screen size, 409–410
and typeface, 409
type size and target audience, 410
type size and visual hierarchy, 410–411
Size/scale, visual aesthetics design, 715
<small> element, 44
Small text, HTML, 44–45, 44f, 45f
SMART goal. See Specific, Measurable, Attainable, Realistic, and Time-bound (SMART) goal,
Smartphones,
content of, 782–784
number of columns, 784
registration, 784
structuring, 783
text entry amount, 784
navigation of, 784–788
touch gestures and animations, 787–788
touch targets, 786–787
Smiley-o-meter gauge, 816, 816f
Software development life cycle (SDLC), 793
Soft wrap, 280
<source> element, 186–187, 186f, 186t
space value, background image, 489, 489f, 490f
Space, visual aesthetics design, 716–718, 718f
span attribute, 75
Special characters, 53–56, 54f, 54t, 55f
non-breaking spaces, 55–56, 55f, 56f
Specific goal, project management, 828
Specificity principle, CSS, 234–236, 234f, 235f, 236t
Specific, Measurable, Attainable, Realistic, and Time-bound (SMART) goal, 828
Spectrum slider, 254
Speech-recognition technology, 65–66
Split complementary scheme, 261–262
Square scheme, 262
src attribute, 685
src property, 392
SSL (Secure Sockets Layer), 744, 824
Standard markup language, 11
“Star_oval.png”, 306
start attribute, 69, 70f
Start tag, 12
Static layout. See Fixed layouts,
Static positioning, 352–353, 352f
Static websites, 6
Stationers’ Company, 856
Statute of Anne, 856
Sticky positioning, 361–366
global navigation, 363–366
Stock,
2D animation, 216–217
images, 179
videos, 210
Storyboard, 799
<strong> element, 40, 44
Structural markup, 22
Structured interviews, 815–816, 816f
Structured Query Language (SQL), 692
<style> element, 15, 240–243, 240f, 241f
style attribute, 224, 224f, 235, 240
Sub-code, 56
Subdominant color, 266
Submit-input types, 111–112, 111t, 112f
Submit() JavaScript function, 114
Sub-pixels, 252
Subscript, 39
Sui generis, 860
database right, 866
summary attribute, 75
<summary> element, 50–51, 50f
Summative evaluation, 801
Superscript, 39
SVG. See Scalable Vector Graphics (SVG),
<svg> element, 154–155, 154f, 155f
SWF format, 169, 213
Symmetrical balance, 721
Synchronization license, 873
Syntactically Awesome Style Sheets (SASS), 681
T
Tab design, guidelines for, 753–754, 753f
Table(s), 542-552. See also Font(s); Text
<rowspan> and <colspan>, 77–78, 78f
<table>, <caption>, <th>, <tr>, and <td>, 74–75, 74f
<thead>, <tbody>, and <tfoot>, 79–80, 79f
border-collapse property, 545
border-spacing property, 546, 546f
cells merging, 77–78
effective, design guidlines, 551–552
elements, 549–551
empty-cells property, 547, 547f
HTML, 72–83, 73f, 73t
and accessibility, 80–83
basic, 74–77
cells’ merging, 77–78, 78f
long, 79–80, 79f
id and headers attributes and accessibility, 81–83, 82f
scope attribute and accessibility, 80–81, 80t, 81f
styling with,
generic properties, 543–545
table-specific properties, 545–549
table-layout property, 548, 548f, 549f
table-layout property, 548, 548f, 549f
Table of content (TOC), 841
format, 831, 832f
Table-specific display values, 549t, 550f
Table-specific properties, 545–549
border-collapse, 545, 546f
border-spacing, 546–547
empty-cells, 547–548
table-layout, 548–549, 548f, 549f
Tablets, 789–790
Tabs metaphor, 749, 752–754
target attribute, 16, 16f, 16t
Task analysis phase, 794–795
field studies, 794–795
HTA, 795, 795f
TCP (Transfer Control Protocol), 2
TCP/IP, 2
Testing plan, 842
Text. See also Font(s) alignment, 421
content alignment, 419–427
centering of block of, 424–427
text-align, 420–421, 420t
vertical-align, 421, 422t, 423f, 424f
content directionality, 436–442
direction property, 436–437
text-combine-upright, 441, 441t, 442f
text-orientation, 440–441, 440f, 440t
writing-mode, 437, 438f, 438t, 439f
decoration, 442–452
text-decoration property, 443, 443f, 443t
text-decoration-skip, 445, 445f, 445t
text-emphasis, 448–450, 448t, 449f
text-shadow, 450–452, 451f, 452f
text-underline-position, 446, 447f, 447t
formatting, 419–442
HTML. See HTML, text indenting and outdenting, 428
line spacing, 432–434
line height in design, 433–434
line-height property, 432–433, 432t
lowercase or uppercase, 434–435
text capitalization, 435
rights in, 872
ruby properties, 466–471
elements conversion to ruby elements, 470–471
for styling and formatting, 466–470
size. See Size of text,
spacing, 429–431, 429t
in design, 431
letter-spacing, font-kerning, and wordspacing, 429–430
text-rendering, 431
style, 414–415
styling,
with pseudo-classes. See Pseudo-classes, text styling with,
with pseudo-elements, 452–457
text-transform property, 434, 434f, 435f
weight, 411–413
font weight in design, 413
font-weight property, 411–412
word wrapping, 431
text-align property, 420–421, 420t
<textarea> element, 120–122, 121t, 122f
Text-based assets, 698–699
text-combine-upright property, 441, 441t, 442f
text-decoration property, 443, 443f, 443t
text-decoration-skip property, 445, 445f, 445t
text-emphasis property, 448–450, 448t, 449f
text-indent property, 428, 428f
text-orientation property, 440–441, 440f, 440t
text-overflow property, 283–285, 284f, 284t
text-rendering property, 431
text-shadow property, 450–452, 451f, 452f
text-transform property, 434, 434f, 435f
text-underline-position property, 446, 447f, 447t
Texture, visual aesthetics design, 719–720, 720f
<thead>, <tbody>, and <tfoot> elements, 79–80, 79f
Think-aloud technique, 822
Three-dimensional (3D) animation. See 3D animation Three.js, 589
Three-line menu navicon, 784–785
Three-point lighting scheme, 180
Time-bound goal, project management, 828
Timed text track, 201
<time> element, 49
Time-input type, 103–104, 103f, 104f
Tints, 253, 253f
title attribute, 13, 143
<title> element, 15
Title page, 841
TLS (Transport Layer Security), 824
Tone, 253, 253f
Top-level domain (TLD), 824
Touch,
activity, 787
gestures,
and animations designing, 787–788, 788t
components, 787
mechanic, 787
targets, 786–787
practical guidelines, 786
<track> element, 201, 202f, 202t
Tracks ripping from discs, 195
Trademarks, 870
Trade Related Aspects of Intellectual Property Rights (TRIPS), 865–866
Transfer Control Protocol (TCP), 2
Transformation of elements, CSS, 335–349
backface-visibility, 346–349
for cube, 347–349
effects of, 347f
perspective, 341–345
application, 343–345
transform, 336–341, 338t–338t
perspective() function, 340–341
rotation and skewing, 338–340
transform-origin property, 335–336
transform-style, 345–346
transform-origin property, 335–336, 336t
effect of changing, 340f
transform property, 336–341, 338t–338t
perspective() function, 340–341
rotation and skewing, 338–340, 339f
transform-style property, 345–346
transition property, CSS, 577–579, 577t–578t
Transparency channel, 168
transparent keyword, 515
Transport Layer Security (TLS), 824
Triadic scheme, 264–265, 264f
Triple constraint, 827, 828f
TRIPS (Trade Related Aspects of Intellectual Property Rights), 865–866
True color, 167
Tweening process, 567, 568f
Two-dimensional images (2D images), 161
type attribute, 69, 70f, 71
Type design, 389
Typeface(s),
body-text, 399–400, 400f
classifications, 397–398
cursive, 398
decorative, 398–399, 399f
display, 399–400, 400f
fantasy, 398–399
and fonts, 390–406
@font-face, 392–396, 393f, 393t, 394f
font-family, 390–392, 391f, 391t
fonts in design, 397–406
font size and, 409
monospaced, 400–401, 401f
proportional, 400–401, 401f
sans serif, 398–399, 398f
script, 398–399, 399f
selection of, 401–406
about rules, 401
availability, 405–406
combining, 404–405
fitness for purpose, 402–403
legibility, 401–402
range, 403
serif, 398–399, 398f
Type family, 390
Typographic scale, 410–411, 411f
Typography, 389
U
UCD process. See User-centered design (UCD) process <u> element, 41
Ultra-high definition (UHD), 204
Unicode bidirectional (bidi) algorithm, 58, 436
Unicode Transformation Format (UTF) standards, 19
Uniform Resource Identifier (URI), 4
Uniform Resource Locator (URL), 3, 4f
Uniform Resource Name (URN), 4
Unity principle, Gestalt effect, 732–738
alignment, 737–738, 737f
closure, 735, 736f
continuity, 736–737, 736f
proximity, 732–733
repetition, 735, 735f
similarity, 733–735
Universal Copyright Convention (UCC), 857
Universal selector (*), 320
Universal Serial Bus (USB), 212
Unordered lists, 67
Unregistered design, 869
Unstructured interviews, 815–816
URI (Uniform Resource Identifier), 4
URL (Uniform Resource Locator), 3, 4f
Usability,
guidelines for long pages, 760–761
laboratory testing, 803
requirements, 796
testing, 801–802
fitts’ law, 809, 809f
hallway testing, 802
heuristic evaluation, 805–807
KLM method, 807–809
paper prototype testing, 803
usability laboratory testing (controlled testing), 803
walkthroughs, 803–805
Use cases, 148
Usefulness, 742
Use inter-frame compression, 210
User agents, 3
User-centered design (UCD) process, 793–825
data collection, 814
data recording, 814–815
design phase, 796–800
card sorting, 797
flowcharts, 797–799, 798f, 799f
paper prototypes, 800
prototypes, 797
wireframes, 799–800, 800f
evaluating websites,
accessibility, 809–812
SEO, 812–814
evaluation phase, 801–809
observational techniques, 820–823
query techniques, 815–820
requirements-gathering phase, 796
stages, 794f
task analysis phase, 794–795
field study, 794–795
HTA, 795
Web, application delivery on, 823–825
User experience (UX), 739–741
accessibility, 741
credibility, 741
desirability, 741
findability, 741
Peter Morville honeycomb, 740f
usability, 740
usefulness, 740
valuability, 741
User flow/journey, 798
User-satisfaction data, 802
UTF-8, 19
UX. See User experience (UX),
V
valueAsNumber property, 128
value attribute, 690–691
Vanishing point, 342, 717
Vector-based images, 141–142
Vector images, 154, 168–170, 168f, 169f, 170f
Verbal techniques. See Query techniques vertical-align property, 421, 422t, 423f, 424f
Vertical balance, 722
Video, 196–212
acquiring, 210–212
production from scratch, 212
ripping video from DVD video/Blu-ray disc, 210–211
stock, 210
from video devices, 211–212, 211f
video screen capture, 212
adding video,
via hosted video services, 197
to Web page, 197–203
and animation, rights in, 874
appropriateness, 205
conciseness, 209
design, 203–209
content in, 205–208
file formats and codecs, 204
file size, 203–204, 203f
guidelines on effective use, 204–209
quality in, 205–208
embedment, 198–203
<video>, 198–202, 198t, 199f, 200f, 200t
<embed> and <object>, 202–203, 202f
file format converters, 200
information, 208–209
recording, 815, 822
screen capture, 212
starting video automatically, 208
Viewport sizes, 149–150, 150f
using media condition, 150–151, 150f
visibility property, hiding content, 332–333, 333f
visible values, 346
Visual aesthetics design, 705–738
elements, 707–720
hue and value, 718–719, 719f, 720f
line, 708–713
point, 707–708, 707f
shapes, 714–715, 714f
size/scale, 715
space, 716–718, 718f
texture, 719–720, 720f
overview, 705–706
principles, 720–738
balance, 720–723
emphasis, 723–727
proportion, 728–732
rhythm, 727–728, 728f
space, 716–718, 718f
Visual Aesthetics of Website Inventory (VisAWI), 706
Visual Artist’s Rights Act (VARA), 862
Visual hierarchy of importance, 33, 723, 724f
Vox-ATypI classification, 397
W
Walkthrough(s), 803–805
code, 803
cognitive, 804–805
pluralistic, 804–805
Warm colors, 256–257, 256f
<wbr> element, 37, 38f
WBS. See Work breakdown structure (WBS),
WCT (WIPO Copyright Treaty), 857
Web,
accessibility requirements, 796
address, 3, 4f
application, 823–825
domain name registration, 823–824
file uploading to web server, 824–825
linking domain name to web server, 824
web hosting company, 824
browser, 3
client, 3
coding languages, 180–181, 217
crawlers, 757
design,
audio in. See Audio, HTML elements for industrial property, 875
development,
cycle, 837
management, 827–836, 828f
process. See User-centered design (UCD) process,
fonts, 390
hosting,
company, 824
services, 2, 823
IP in web design, 872–875
codes and database, 875
images and photographs, 872–873
music and speech, 873–874
text, 872
video and animation, 874
languages, 810
page,
design components, 746f
on desktop and smartphone, 782f
production, 858
project management phases, 837–852, 837f
appendices, 844
contract process, 844–847, 846f
initiation phase, 837–844
postproduction, 851–852
preproduction, 848–851
production, 851
project management tools, 829–836
brainstorming, 830–831
CPM, 832–835, 833f, 833t, 834f
gantt chart, 836, 836f
WBS, 831–832, 831f, 832f
server,
linking domain name, 824
uploading files, 824–825
servers, 2
Web Content Accessibility Guidelines (WCAG), 801
Web content management systems (WCMSs), 6, 29
Web Graphics Library (WebGL), 589
Web Hypertext Application Technology Working Group (WHATWG), 28
-webkit- declaration, 525
Websafe fonts, 405
Website(s),
content area, 758–778
accordion menus, 766–767, 766f
carousels, 767–769, 768f
collapsing text technique, 765
content amount management, 765–769
content layout, 761–765
content length, 760–761
creation for Web, 770–777
display size, 758–760
F-shaped pattern, 764–765, 765f
gutenberg rule, 762–763, 762f
homepage content, 758
for international audience, 775
line length, 761
scannable text, 770–771
writing FAQs, 776–778
writing links, 775–776
writing style, 772–774
z-pattern, 763–764, 763f
credibility, 741–745
adverts management, 743
professionalism, 742–743
trustworthiness, 743–745
usefulness, 742
design process, 849–850
evaluating for accessibility, 809–812
conformance, 810–812, 812f
evaluation for SEO, 812–814
ID, 749
interface designing, 745–778
navigation, 747–758
drop-down menus, 754–755
footers, 757–758
site map, 755–757, 756f
tabs metaphor, 752–754
performance optimization, 697–701
image-based assets, 699–700
text-based assets, 698–699
web font, 700–701
requirements for creation of, 6
UX, 739–741
Web-specific languages, 181
Web Video Text Tracks (WebVTT), 201, 201f
WebVTT (Web Video Text Tracks), 201, 201f
Week-input type, 107, 107f
White space collapsing, 14
white-space property, 282–283, 282f, 282t, 283f
width and height property, 474f
CSS box, 276–278, 276f
specifying logical, 277–278, 277f, 278f
Window events attributes, 13
WIPO Copyright Treaty (WCT), 857
WIPO Performances and Phonograms Treaty (WPPT), 857, 865
Wireframes, 799–800, 800f
Within-page linking, 86
Wood.png, 485
Word-break opportunities, 37–38
word-wrap element, 285
Work breakdown structure (WBS), 829, 831–832, 832f
web project, 831f
World Intellectual Property Organization (WIPO), 856
World Wide Web (WWW), 1, 4
World Wide Web Consortium (W3C), 28
WPPT (WIPO Performances and Phonograms Treaty), 857, 865
writing-mode property, text, 437, 438f, 438t, 439f
Wroblewki, Luke, 663
WYSIWYG HTML editors, 29
X
XMLHttpRequest, 690
Y
YUV color model, 252
Z
z-index property, grid item, 651–652, 651f
z-pattern, 763–764, 763f