You are previewing Mastering Responsive Web Design with HTML5 and CSS3.
O'Reilly logo
Mastering Responsive Web Design with HTML5 and CSS3

Book Description

Push your HTML and CSS skills to the limit and build professional grade, responsive websites

About This Book

  • Take your RWD skills to the next level with HTML5 and CSS3 best practices that will give you a solid foundation to build out from
  • Harness the power of the CSS pre-processor Sass to speed up the creation of your CSS
  • Each chapter dives deep in to different aspects of RWD and is designed to get you up to speed with the latest developments in professional web design
  • Who This Book Is For

    If you’re already building responsive designs and are looking to level up your skills, then Mastering Responsive Web Design is the book for you. Regardless of whether you’re a web designer, or web developer, you’ll find something here to help you in your responsive design journey.

    What You Will Learn

  • Install and use Sass with SCSS syntax to create your CSS
  • Use HTML5 tags the right way, for the right type of content
  • Enhance the experience of users with assistive technology with ARIA roles
  • Design with a desktop-first approach, but implement with mobile-first methodology
  • Master your layouts by creating your own scalable CSS grid, or using Flexbox for total layout ‘flexibility’
  • Retrofit your old web sites with your new responsive design skills
  • Deal with legacy browsers, and learn how to keep your designs consistent
  • Implement widely used responsive patterns, such as the “drawer navigation”, the “off-canvas” and the “flexbox-based” navigation patterns
  • Find the best way to serve the right type of image and how to make videos responsive
  • Build custom responsive emails to ensure the message gets across regardless of the device
  • In Detail

    Building powerful and accessible websites and apps using HTML5 and CSS3 is a must if we want to create memorable experiences for our users. In the ever-changing world of web design and development, being proficient in responsive web design is no longer an option: it is mandatory.

    Each chapter will take you one step closer to becoming an expert in RWD. Right from the start your skills will be pushed as we introduce you to the power of Sass, the CSS preprocessor, to increase the speed of writing repetitive CSS tasks. We’ll then use simple but meaningful HTML examples, and add ARIA roles to increase accessibility. We’ll also cover when desktop-first or mobile-first approaches are ideal, and strategies to implement a mobile-first approach in your HTML builds.

    After this we will learn how to use an easily scalable CSS grid or, if you prefer, how to use Flexbox instead. We also cover how to implement images and video in both responsive and responsible ways. Finally, we build a solid and elegant typographic scale, and make sure your messages and communications display correctly with responsive emails.

    Style and approach

    Designing and developing for the web should be fun, and that’s the tone used in the book. This book is written in a step-by-step format with clean-cut examples. You will also find tips and notes all over the book to help clarify those small and simple details most books and tutorials assume you already know.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. Mastering Responsive Web Design with HTML5 and CSS3
      1. Table of Contents
      2. Mastering Responsive Web Design with HTML5 and CSS3
      3. Credits
      4. About the Author
      5. Acknowledgment
      6. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      9. 1. Harness the Power of Sass for Responsive Web Design
        1. How does Sass work?
          1. Installing Sass
            1. Downloading the Ruby installer
            2. Opening the command line
            3. Installing the Sass gem
          2. Using Sass
        2. The basic concepts of Sass for RWD
          1. Sass or SCSS
            1. The Sass syntax
            2. The SCSS syntax
            3. Sass variables
            4. Sass mixins
          2. Sass arguments
            1. How to use several arguments in the same mixin
            2. Setting default values in multiple arguments
          3. Nesting in Sass
          4. Partial files (partials) in Sass
          5. The Sass extend/inherit feature
          6. Sass comments
          7. Vendor prefixing
            1. The order of vendor prefixing
            2. Automating vendor prefixing
              1. Using Compass
              2. Using -prefix-free
              3. Using Autoprefixer
              4. Using Pleeease
              5. Using Emmet
              6. Using a third-party application
              7. The recommended vendor prefixing method
          8. Using a third-party program to compile
            1. The Prepros app
              1. Expanded output
              2. Nested output
              3. Compact output
              4. Compressed output
              5. Add some CSS and let the Prepros app do the rest!
              6. Defining how many legacy browser versions to support for prefixing
            2. One compiler only
          9. Sass mixins to house our media queries
            1. Media queries mixin methods
              1. Let the content define the breakpoints
                1. Mixin
              2. Named media queries
              3. The basic mixin
        3. Summary
      10. 2. Marking Our Content with HTML5
        1. The <main> element
        2. The <article> element
        3. The <section> element
        4. The <aside> element
        5. The <header> element
        6. The <footer> element
        7. The <nav> element
        8. Using WAI-ARIA landmark roles to increase accessibility
          1. WAI-ARIA landmark roles
            1. The banner role
            2. The navigation role
            3. The main role
            4. The contentinfo role
            5. The search role
            6. The form role
            7. The complementary role
          2. Important meta tags to consider for RWD
            1. The viewport meta tag
            2. The X-UA-Compatible meta tag
            3. The charset meta tag
        9. A full HTML5 example page with ARIA roles and meta tags
        10. Output screenshots for desktop and mobile
        11. Summary
      11. 3. Mobile-first or Desktop-first?
        1. Create your designs in a desktop-first view, but implement them with mobile-first
          1. Why create designs in a desktop-first view?
          2. Why implement with mobile-first?
        2. Sass mixins for the mobile-first and desktop-first media queries
          1. The mobile-first mixin
          2. The desktop-first mixin
        3. Dealing with legacy browsers
          1. How to use Respond.js for RWD
          2. The days of an IE-specific style sheet are dead
            1. Other benefits of not using an IE-specific style sheet
              1. Use conditional classes in the <html> tag
        4. How to deal with high-density screens
          1. Bitmaps or vectors for high-density screens?
        5. Sometimes RWD is not necessarily the right solution
        6. Retrofitting an old website with RWD
          1. The base page
          2. HTML
          3. CSS/SCSS
            1. Creating the _980gs.scss file
        7. Retrofitting with AWD
          1. Creating the styles.scss file
            1. 980px to 768px (AWD)
            2. 768px to 640px (AWD)
            3. 640px to 480px (AWD)
            4. 480px to 320px (AWD)
        8. Retrofitting with RWD
          1. The RWD magic formula
          2. The main container
          3. The Header and Footer sections
          4. The Nav section
          5. The Content section
            1. 980px to 768px (RWD)
            2. 768px to 640px (RWD)
            3. 640px to 480px (RWD)
            4. 480px to 320px (RWD)
        9. Summary
      12. 4. CSS Grids, CSS Frameworks, UI Kits, and Flexbox for RWD
        1. What is a grid?
        2. CSS grids
          1. The pros and cons of CSS grids for RWD
        3. CSS frameworks
        4. UI kits
        5. The pros and cons of CSS frameworks for RWD
        6. Creating a custom CSS grid
          1. Doing the math
          2. Adding the UTF-8 character set directive and a Credits section
          3. Including the box-sizing property and the mobile-first mixin
          4. The main container and converting 10px to percentage value
          5. Making it mobile-first
          6. Adding the row and float clearing rules
        7. Building a sample page with the custom CSS grid
          1. Nested containers
        8. Stop using CSS grids, use Flexbox!
          1. Building a sample page with Flexbox
            1. The HTML
            2. The SCSS
            3. Adding the Flexbox container
              1. DIVs inside the Flexbox container
            4. The Header, Footer, Nav, and Section Containers
            5. Nested containers
            6. Supporting old IEs
              1. One rule to rule them all
              2. Rules for both IE8 and IE9
              3. Specific rules for IE8 and IE9
        9. Summary
      13. 5. Designing Small UIs Driven by Large Finger
        1. The ideal target sizes on small UIs
        2. The posture patterns and the touch zones
          1. The posture patterns
          2. The touch zones
        3. The nav icon – basic guidelines to consider for RWD
          1. The hamburger icon
          2. The word Menu
          3. The hamburger icon plus the word Menu
        4. The navigation patterns for RWD
          1. Design
          2. Scope
          3. Third-party demos
          4. The Off-Canvas or Off-Screen navigation
          5. The Toggle navigation
          6. The Flexbox-based navigation
        5. Summary
      14. 6. Working with Images and Videos in Responsive Web Design
        1. Tips for reducing the file size in images for RWD
          1. Resizing
          2. Blurring the background
          3. Darkening or lightening the less important areas
          4. Optimizing an image
            1. Using Adobe Fireworks (optional)
            2. Compressing the image
        2. Third-party image resizing services
        3. The <picture> element and the srcset and sizes attributes
          1. When to use <picture> and when to use srcset
          2. Implementing the Picturefill polyfill
          3. Using the <picture> element
          4. Using the srcset and sizes attributes
            1. Targeting high-density screens with srcset
          5. <picture> versus srcset
        4. Replacing 1x images with 2x images on the fly with Retina.js
          1. Retina.js – a JavaScript solution
            1. Excluding images
          2. Retina.js – a Sass mixin solution
        5. Making videos responsive
          1. Responsive videos with HTML and CSS
          2. Responsive videos with jQuery
          3. Responsive videos with plain JavaScript
          4. Third-party services to embed video
        6. The Vector Formats
          1. Vectors or bitmaps/raster images
          2. Icon fonts
            1. Implementing icon fonts
              1. Using a pseudo-element
              2. Using an extra HTML element
          3. Scalable Vector Graphics
            1. Inline via the <svg> tag
              1. Providing fallback images to legacy browsers for inline SVGs
                1. Using the <foreignObject> and <img> tags
                2. Using an <image> tag
            2. File-based with the xlink:href and src attributes
              1. Other sources to learn about SVG
        7. Summary
      15. 7. Meaningful Typography for Responsive Web Design
        1. Pixels, ems, or rems for typography?
        2. Calculating relative font sizes
        3. Creating a Modular Scale for a harmonious typography
          1. Defining the first base number
          2. Defining the second base number
          3. Choosing a ratio
        4. Using the Modular Scale for typography
          1. The rems-to-pixels Sass mixin
        5. Web fonts and how they affect RWD
        6. Sass mixin for implementing web fonts
        7. Using FlowType.js for increased legibility
          1. Defining thresholds
            1. Threshold widths
            2. Threshold font sizes
        8. Summary
      16. 8. Responsive E-mails
        1. Why do we need to worry about responsive e-mails?
        2. Don't overlook your analytics
        3. Recommendations for building better responsive e-mails
        4. Responsive e-mail build
          1. Modular Scale for typography
          2. Design – large and small screen views
          3. Setting up a basic HTML template
            1. Using CSS reset to normalize display
            2. Adding the e-mail content
              1. Creating a 100 percent wide wrapping table
              2. Creating the 600px inner table
              3. Adding the header image
              4. Creating the content wrapping table and all its content
              5. Adding the Outlook 2007/2010/2013 Conditional Comments hacks
                1. Conditional Comments for the background image in the footer
                2. Conditional Comments for the CTA buttons
              6. Adding media queries
              7. Outlook web font fallback style
                1. Screenshot of various e-mail clients
        5. Third-party services
          1. Litmus's PutsMail
          2. CSS inliners
          3. Advanced e-mail frameworks
          4. Responsive e-mail template services
          5. See how an e-mail was built
        6. Summary
      17. Index