Responsive Web Design with HTML5 and CSS
eBook - ePub

Responsive Web Design with HTML5 and CSS

Develop future-proof responsive websites using the latest HTML5 and CSS techniques, 3rd Edition

Ben Frain

Partager le livre
  1. 408 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Responsive Web Design with HTML5 and CSS

Develop future-proof responsive websites using the latest HTML5 and CSS techniques, 3rd Edition

Ben Frain

Détails du livre
Aperçu du livre
Table des matières

À propos de ce livre

Publisher's note: To make use of the most recent CSS and HTML features, a new, fully revised fourth edition of this book is now available, updated for 2022.

Key Features

  • Understand what responsive web design is and its significance for modern web development
  • Explore the latest developments in responsive web design including variable fonts, CSS Scroll Snap, and more
  • Get to grips with the uses and benefits of the new CSS Grid layout

Book Description

Responsive Web Design with HTML5 and CSS, Third Edition is a renewed and extended version of one of the most comprehensive and bestselling books on the latest HTML5 and CSS tools and techniques for responsive web design.

Written in the author's signature friendly and informal style, this edition covers all the newest developments and improvements in responsive web design including better user accessibility, variable fonts and font loading, CSS Scroll Snap, and much, much more. With a new chapter dedicated to CSS Grid, you will understand how it differs from the Flexbox layout mechanism and when you should use one over the other.

Furthermore, you will acquire practical knowledge of SVG, writing accessible HTML markup, creating stunning aesthetics and effects with CSS, applying transitions, transformations, and animations, integrating media queries, and more. The book concludes by exploring some exclusive tips and approaches for front-end development from the author.

By the end of this book, you will not only have a comprehensive understanding of responsive web design and what is possible with the latest HTML5 and CSS, but also the knowledge of how to best implement each technique.

What you will learn

  • Integrate CSS media queries into your designs; apply different styles to different devices
  • Load different sets of images depending upon screen size or resolution
  • Leverage the speed, semantics, and clean markup of accessible HTML patterns
  • Implement SVGs into your designs to provide resolution-independent images
  • Apply the latest features of CSS like custom properties, variable fonts, and CSS Grid
  • Add validation and interface elements like date and color pickers to HTML forms
  • Understand the multitude of ways to enhance interface elements with filters, shadows, animations, and more

Who this book is for

Are you a full-stack developer who needs to gem up on their front-end skills? Perhaps you work on the front-end and you need a definitive overview of all modern HTML and CSS has to offer? Maybe you have done a little website building but you need a deep understanding of responsive web designs and how to achieve them? This is a book for you!

All you need to take advantage of this book is a working understanding of HTML and CSS. No JavaScript knowledge is needed.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans param√®tres et de cliquer sur ¬ę¬†R√©silier l'abonnement¬†¬Ľ. C'est aussi simple que cela¬†! Une fois que vous aurez r√©sili√© votre abonnement, il restera actif pour le reste de la p√©riode pour laquelle vous avez pay√©. D√©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptés aux mobiles peuvent être téléchargés via l'application. La plupart de nos PDF sont également disponibles en téléchargement et les autres seront téléchargeables très prochainement. Découvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accès complet à la bibliothèque et à toutes les fonctionnalités de Perlego. Les seules différences sont les tarifs ainsi que la période d'abonnement : avec l'abonnement annuel, vous économiserez environ 30 % par rapport à 12 mois d'abonnement mensuel.
Qu'est-ce que Perlego ?
Nous sommes un service d'abonnement √† des ouvrages universitaires en ligne, o√Ļ vous pouvez acc√©der √† toute une biblioth√®que pour un prix inf√©rieur √† celui d'un seul livre par mois. Avec plus d'un million de livres sur plus de 1¬†000¬†sujets, nous avons ce qu'il vous faut¬†! D√©couvrez-en plus ici.
Prenez-vous en charge la synthèse vocale ?
Recherchez le symbole √Čcouter sur votre prochain livre pour voir si vous pouvez l'√©couter. L'outil √Čcouter lit le texte √† haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l'acc√©l√©rer ou le ralentir. D√©couvrez-en plus ici.
Est-ce que Responsive Web Design with HTML5 and CSS est un PDF/ePUB en ligne ?
Oui, vous pouvez accéder à Responsive Web Design with HTML5 and CSS par Ben Frain en format PDF et/ou ePUB ainsi qu'à d'autres livres populaires dans Design et Web Design. Nous disposons de plus d'un million d'ouvrages à découvrir dans notre catalogue.


Packt Publishing
Web Design


CSS Selectors, Typography, Color Modes, and More

In the last few years, CSS has enjoyed a raft of new features. Some enable us to animate and transform elements. Others allow us to create multiple background images, gradients, and mask and filter effects, and others allow us to bring SVG elements to life.
We will get to all those capabilities in the next few chapters. Firstly, I think it will be useful to look at more recent improvements to some of the fundamentals of CSS.
No one can know every nuance, capability, and syntax in the CSS language. I've been working with CSS for two decades and on a weekly basis I still discover something new (or just as likely rediscover something I'd forgotten). As such, I don't feel that trying to know every possible CSS property and value permutation is actually a worthy pursuit. Instead, I think it's more sensible to develop a good grasp of what's possible and what capabilities exist that solve the most common problems.
As such, we are going to concentrate in this chapter on some of the techniques, units, and selectors I have found most useful when building responsive web designs. I'm hoping you'll then have the requisite knowledge to solve most problems that come your way when developing a responsive web design.
As there are quite a few topics to cover they have been grouped:
Selectors, units, and capabilities:
  • ::before and ::after pseudo-elements
  • Attribute selectors and substring matching
  • Structural pseudo-classes, including :last-child, :nth-child, :empty, and :not
  • Combinator selectors, including child, next sibling, and subsequent sibling
  • Viewport related length units: vh, vw, vmax, and vmin
  • The calc() function
  • CSS custom properties and environment variables
  • Using @supports to fork CSS
Web typography:
  • @font-face rule
  • Font formats, including .woff and .woff2
  • Font loading control with the font-display property
  • Variable fonts and font features
  • RGB
  • HSL
  • RGBA and HSLA
As you can see, we have a lot to get through. Let's begin.

Selectors, units, and capabilities

Although they may not seem like the most exciting of subjects, selectors, units, and capabilities are the "meat and potatoes" of CSS. Master these and your power to solve problems with CSS will increase substantially. So, skip this section at your peril!

Anatomy of a CSS rule

Before exploring some of the recent additions to CSS, to prevent confusion, let's establish the terminology we use to describe a CSS rule. Consider the following example:
.round { /* selector */ border-radius: 10px; /* declaration */ } 
This rule is made up of the selector (.round) and then the declaration (border-radius: 10px). The declaration is further defined by the property (border-radius) and the value (10px). Happy we're on the same page? Great, let's press on.
At the time of writing this, the Selectors Level 4 working draft details a host of new selectors such as is(), has(), and nth-col. Sadly, there is not a single implementation in any of the common browsers available. However, if you want to see how things are shaping up for the future, head to the draft at

Pseudo-elements and pseudo-classes

There is potential for some confusion when we go on shortly to talk about "pseudo" selectors. The reason being is that, in CSS, there are both pseudo-selectors and pseudo-elements. Let's therefore take a moment to establish the difference.
The word "pseudo" in this context means something that is like something but not really it. So, a pseudo-element is something that is like an element but not really one, and a pseudo-selector is something that selects something that isn't really something. Wow, I'm sounding like the Riddler now from Batman! Let's clarify with some code. Here is how you create a pseudo-element in CSS:
.thing::before { content: "Spooky"; } 
That inserts a ::before pseudo-element into the .thing element with the content "Spooky." A ::before behaves like a first child of the element and an ::after behaves like a last child.
The following image might help. It's showing a single element represented in the Firefox developer tools, containing text with both a ::before and an ::after pseudo-element added in CSS:
Figure 6.1: The Firefox developer tools will show you where pseudo-elements are in the DOM
The key thing to remember with pseudo-elements is that if you don't provide a value for content, nothing will show on the page. Notice the double colon before before? Officially, that is how you should code pseudo-elements as it helps differentiate them from pseudo-selectors, which only use one. However, a single colon worked with the first implementations of ::before and ::after and so you can still write them that way too.
You can't do the same with pseudo-selectors; they always have a single colon. For example, :hover, :active, and :focus are all pseudo-selectors and are written with a sin...

Table des matières