Learn how deep the CSS3 rabbit hole goes in this jam-packed course with CSS luminary Estelle Weyl. Estelle dives deep into the various components of CSS3 including: selectors, specificity, generated content, media queries, debugging, colors, fonts, shadows, text-effects, borders, backgrounds, gradients, transforms, transitions, animations…and more!
Estelle is an engineer, author, and trainer who has been developing standards-based accessible websites since 1999. She is a frequent speaker at tech conferences around the world.
HTML5 & CSS3 in the Real World
Part 1: Selectors
0:05:52 - 0:12:11
Basic selectors, relational selectors
Definition and explanation of both basic and relational selectors
- 0:12:12 - 0:25:13 Attribute selectors Attribute selectors can be used to style elements based on the existence or value of an attribute.
- 0:25:14 - 0:37:23 UI pseudo-classes UI pseudo classes are based on the current state or structure of the UI. For example, a style may be applied if an item is enabled, disabled or checked.
- 0:37:24 - 0:48:18 Structural UI pseudo-classes UI pseudo-classes can also target elements based on their relationship to other elements in the DOM. The first step is to understand the difference between child and type.
- 0:48:19 - 1:00:35 Demonstration of Structural UI pseudo-classes Estelle demonstrates some techniques using structural pseudo classes to create different column widths and design a US Flag
- 1:00:36 - 1:08:25 Negation and empty pseudo-classes The negation pseudo-class can add exclusion to a CSS rule.
- 1:08:26 - 1:15:13 Other pseudo-classes Estelle finishes up covering a few additional pseudo-classes and demonstrates some uses cases for each one. The additional pseudo elements include :lang, :target, and :root.
- 1:15:14 - 1:26:34 Pseudo-elements While pseudo-classes classes select elements that already exist, pseudo-elements create “faux” elements that you can style. Pseudo elements are often indicated by double-colon notation however for IE support, single colons should be used.
- 0:05:52 - 0:12:11 Basic selectors, relational selectors Definition and explanation of both basic and relational selectors
Part 2: Specificity
- 1:26:35 - 1:37:57 Understanding Specificity Element selectors carry the least “weight” when it comes to specificity. From there, adding classes or pseudo-classes increase the weight of a selector. IDs carry the most weight in specificity. Estelle walks through her “Speci-FISH-ity” chart describing how these rules relate to specificity.
Part 3: Generated Content
- 1:37:58 - 1:48:34 Generated content Generated content is content created with CSS that can be placed before or after the content of an element. The difference is the generated content is not part of the DOM.
- 1:48:35 - 1:57:56 Other values for generated content Incorporating images and counters in the generated content can be useful. Estelle demonstrates a few of these techniques and also describes a use-case for sprite sheets.
- 1:57:57 - 2:10:05 Use-cases for generated content Estelle demonstrates some common use-cases for generated content. These include adding iconography and tool-tip hover effects based on href values.
2:10:06 - 2:18:32
Generated content example by Chris Coyer
There are many more generated content example on the CSS-Tricks.com website. Some incorporate shapes created with CSS. Others add complex graphical effects or interactive content.
- 2:18:33 - 2:34:56 Generated content code example Estelle codes a more complex generated content hover interaction.
Part 4: Media Queries
- 2:34:57 - 2:45:42 Introduction to media queries Print and screen media queries have been used for many years in web development. With the multi-device landscape, media queries around screen width, height, and orientation are more widely used.
2:45:43 - 2:48:54
The viewport of a webpage has traditionally been set in an HTML meta element, however this is not appropriate for presentation. CSS adds a “@viewport” declaration that allows the viewport to be set via CSS.
Part 5: Debugging
- 2:48:55- - 2:54:29 Debugging in the browser Most modern browser, both mobile and desktop, have tools for debugging content in-browser. Some browser debuggers and better than others.
2:54:30 - 3:02:58
Debugging mobile browsers
With mobile devices, it’s helpful to use a remote debugger to inspect the DOM of the content as it’s rendered in the device’s browser. Using Weinre, remote debugging can be done very easily.
Part 6: Colors
- 3:02:59 - 3:12:46 CSS color formats There are a variety of color formats in CSS include hexadecimal, RGB, RGBA, HSA, and HSLA. The “A” in RGBA and HSLA stands for “alpha” or transparency.
- 3:12:47 - 3:18:15 Transparency and color tips Reducing an object’s opacity will make both the object and its children transparent. It’s often better to use a background color with transparency so the children of the object aren’t affected. Using RGBA or HSLA is often best for shadows.
Part 7: Fonts, Shadows, and Text Effects
- 3:18:16 - 3:24:45 CSS Fonts The font-face rule declares a font family that can be used within a CSS document. It’s important to know what font types are compatible in different browsers.
3:24:46 - 3:35:26
Font licensing can be an issue with web fonts. Also, font files are large and can take a while to download. Using a font service like Google Fonts will help with both of these issues.
- 3:35:27 - 3:49:35 Text Shadows and Box Shadows The key to a good-looking shadow is transparency. Don’t use opaque shadows. The four settings for a shadow are left, top, blur and color.
Part 8: Borders and Backgrounds
- 3:49:36 - 3:59:31 Background Images Previously, developers often used the background shortcut in css to declare their backgrounds. Estelle describes why that’s not a best practice any more.
- 3:59:32 - 4:09:12 Background repeat, attachment and position Repeated backgrounds are controlled with the background-repeat property. This enables vertical/horizontal tiling or allows developers to turn off repeating.
- 4:09:13 - 4:15:05 Background clip, origin and size The background-clip property in CSS indicates which part of the background is showing. Background origin indicates where you the background image begins. When considering hiDPI images, the background-size property determines how backgrounds will grow or shrink.
- 4:15:05 - 4:23:41 Border properties When declaring border properties, they follow the top-right-bottom-left shorthand rules. Unlike backgrounds, it’s acceptable to use the border shorthand syntax.
- 4:23:42 - 4:29:40 Border images Border images are use a 9-slice scaling technique where the images is “sliced” into nine regions and the corners maintain their aspect ratio while the other regions shrink/grow.
Part 9: Gradients
- 4:29:41 - 4:35:29 Gradients Gradients can theoretically be used anywhere an image can be used. There are four gradient types. Currently there are three different syntaxes to support. The first is the original Webkit syntax.
- 4:35:30- - 4:41:17 Prefixed, linear gradients The prefixed, older linear gradient syntax is another version of the gradient syntax that is still supported in web browsers. This syntax requires a vendor prefix
4:41:18 - 4:50:22
W3C Standard syntax
The final linear gradient syntax is the W3C standard syntax which enables a number of additional techniques like hard-stops, color-stops and endpoints.
- 4:50:23 - 4:58:56 Radial Gradients Estelle demonstrates a number of useful techniques for using radial gradients in CSS.
Part 10: Transforms
- 4:58:57 - 5:09:55 Transforming elements In CSS, there are a number of two-dimensional transform functions that will move, scale, rotate and skew elements.
- 5:09:56 - 5:15:43 2D vs. 3D transformations Estelle begins experimenting with different 2d transformations and explains various customizations like transform-origin
Part 11: Transitions & Animations
5:15:44 - 5:23:12
Transitions can be as simple as changing the color of a link on hover. Adding a duration makes those transitions animate. Any property with an intermediate value can be transitioned.
5:34:57 - 5:43:05
Attaching animations to elements
Animations are attached to elements using the animation-name property as well as animation-duration property. In addition, the animation-timing-function can be applied to change the way the animation plays.
- 5:43:06 - 5:50:33 Advanced animation properties While hard to read, the animation shorthand syntax can make your code less verbose. There are also other properties like animation-fill-mode and animation-delay that give you a more granular control of your animations.
- 5:15:44 - 5:23:12 Transition Basics Transitions can be as simple as changing the color of a link on hover. Adding a duration makes those transitions animate. Any property with an intermediate value can be transitioned.
Part 12: Other CSS Features
- 5:50:34 - 5:58:45 Other CSS features, part 1 Estelle quickly covers a number of additional CSS features including multi-column content, box sizing, CSS regions, and CSS exclusions.
- 5:58:46 - 6:00:53 Other CSS features, part 2 Estelle continues here brief coverage of additional CSS features that currently are not widely supported but worth noting. They include the new flexible box model, grid layouts, CSS shaders, cursors, text wrapping, the calc method, and rem units
- 6:10:08 - 6:15:37 Conclusion Estelle concludes with a few additional resources and a brief quiz to test your recognition of CSS properties.