Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Mastering CSS
Mastering CSS

Mastering CSS: A guided journey through modern CSS

eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Mastering CSS

Ramping Up

In order to be a great coder, you need to ramp up and learn about things that will help you become a better developer. In this chapter, we're going to look at text editors that will speed up our workflow. We'll then look at a CSS reset, which resets the default browser such that its styling is reduced to nothing, and the built-in browser developer tools to help us troubleshoot our code. Then, we'll look at how to rename elements with classes and IDs as well as qualify our selectors using descendant selectors.

Text editors

HTML, CSS, and JavaScript can be written in any text-editing application. This is one of the great things about the three core web languages. The problem is that writing HTML, CSS, and JavaScript is extremely error-prone. For CSS, commas, semicolons, and curly braces need to be typed in the right spots. A specific syntax needs to be adhered to perfectly in most cases, else your page won't render as expected. The following is an illustration of TextEdit for Mac. It's similar in nature to Notepad for Windows, in that it doesn't have many features that make writing code easy:

Let's write some code in TextEdit anyway. We start with the HTML doc type. Post this, we add an HTML opening and closing tag and then the head tag and inside that the title tag. You'll soon realize that it's a pretty tedious process, that is, writing code in TextEdit...

CSS reset

In the last section, you learned about the power of a good text editor. In this section, we're going to use that text editor to explore something called a CSS reset. There's a lot of pieces to starting a website that need to be in place and are typically part of your website boilerplate. I call these pieces your "base layer". A big part of this base layer is the CSS reset. A reset allows you to eliminate browser inconsistencies with regard to default browser styling and eliminate all default browser styles in general. It allows you to more easily provide your handcrafted styles using CSS. In this section, we're going to first load in a CSS reset, then examine that reset and see what it's doing. Finally, we'll add to and customize the reset to fit our needs.

...

Chrome DevTools

Most of the CSS we have done so far has been fairly simple. Everything we did worked the first time we tried, and that doesn't always happen. Often, CSS doesn't work and I'm left wondering what I missed. Syntax highlighting in my editor, while helpful, doesn't stop me from overlooking mistakes. Usually, it's a tiny mistake that causes something not to work and it's hard to find the error and fix it. In this section, we'll simply look at how to open up DevTools. Then, we'll modify some CSS in the inspector and finally look at the console to find errors.

How to open developer tools

To open up Chrome's DevTools, all you need to do is right-click or Ctrl + click on any...

Renaming elements — classes and IDs

Renaming elements is such a powerful feature of CSS. Let me set this up for you. So far, CSS has been good because we have been able to keep things consistent. All heading 1s are blue with a font size of 20 pixels, for instance, but what if you want your h1 to look different? That's where renaming and classifying elements really becomes useful. In this section, you're going to learn about how to rename and style elements based on classes and IDs. We'll look at how this will pay off on our shark website, first with classes, followed by IDs.

Classes

Look at the index.html file. You can see there are several HTML5 <section> tags throughout the page: one in the initial...

Descendant selectors

Renaming elements with classes, as you learned in the previous section, is an extremely powerful feature in CSS. However, that's not the only way to target a specific type of element. Descendant selectors will allow you to target elements on a page based on their ancestor elements. This is often necessary because you only want to apply a margin or a new font based on the context of the element. You can use a descendant selector to get that context without putting a class on every element every time you want to target it. I'm going to first explain what parent, sibling, and child elements are as well as what ancestor and descendant elements are. We'll need to be clear about these if we want to use descendant selectors. We'll follow this up by using a practical example of the descendant selector and finishing up by calculating the descendant...

Summary

In this chapter, you learned about the features of a good text editor, discussed CSS resets, explored the troubleshooting power of Chrome's DevTools, and learned how to rename elements with classes. In the final section of this chapter, you learned about descendant selectors.

The next chapter is about creating a multicolumn layer using floats and understanding the solutions to the problems that floats cause.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn CSS directly from Rich Finelli, author of the bestselling Mastering CSS training course
  • From best practices to deep coding, Rich Finelli shares his CSS knowledge with you
  • Rich Finelli covers the latest CSS updates with flexbox and works with retina devices

Description

Rich Finelli trains you in CSS deep learning and shows you the techniques you need to work in the world of responsive, feature-rich web applications. Based on his bestselling Mastering CSS training video, you can now learn with Rich in this book! Rich shares with you his skills in creating advanced layouts, and the critical CSS insights you need for responsive web designs, fonts, transitions, animations, and using flexbox. Rich begins your CSS training with a review of CSS best practices, such as using a good text editor to automate your authoring and setting up a CSS baseline. You then move on to create a responsive layout making use of floats and stylable drop-down menus, with Rich guiding you toward a modular-organized approach to CSS. Your training with Rich Finelli then dives into detail about working with CSS and the best solutions to make your websites work. You'll go with him into CSS3 properties, transforms, transitions, and animations. You’ll gain his understanding of responsive web designs, web fonts, icon fonts, and the techniques used to support retina devices. Rich expands your knowledge of CSS so you can master one of the most valuable tools in modern web design.

Who is this book for?

This book is for web designers who wish to master the best practices of CSS in their web projects. You already know how to work with a web page, and want to use CSS to master website presentation.

What you will learn

  • Master fundamental CSS concepts like the anatomy of a rule set, the box model, and the differences between block and inline elements
  • Employ flexbox to layout and align elements simply and cleanly
  • Become proficient with CSS3 properties such as transitions, transforms, gradients, and animations
  • Delve into modular, reusable, and scalable CSS for more organized and maintainable style sheets
  • Understand media queries and other pillars of responsive web design
  • Get creative with the @font-face property, Google Web Fonts, font services such as Typekit, as well as, icon fonts
  • Understand the workflow for HiDPI (retina) devices using 2x images, SVG, and the srcset attribute
Estimated delivery fee Deliver to Malta

Premium delivery 7 - 10 business days

€32.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 06, 2017
Length: 522 pages
Edition : 1st
Language : English
ISBN-13 : 9781787281585
Languages :
Concepts :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Malta

Premium delivery 7 - 10 business days

€32.95
(Includes tracking information)

Product Details

Publication date : Oct 06, 2017
Length: 522 pages
Edition : 1st
Language : English
ISBN-13 : 9781787281585
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 237.97
HTML5 and CSS3: Building Responsive Websites
€73.99
Mastering CSS, Second Edition
€130.99
Mastering CSS
€32.99
Total 237.97 Stars icon

Table of Contents

11 Chapters
CSS Foundations Chevron down icon Chevron up icon
Ramping Up Chevron down icon Chevron up icon
Creating a Page Layout with Floats Chevron down icon Chevron up icon
Creating Buttons with Modular, Reusable CSS Classes, and CSS3 Chevron down icon Chevron up icon
Creating the Main Navigation and Drop-Down Menu Chevron down icon Chevron up icon
Becoming Responsive Chevron down icon Chevron up icon
Web Fonts Chevron down icon Chevron up icon
Workflow for HiDPI Devices Chevron down icon Chevron up icon
Flexbox, Part 1 Chevron down icon Chevron up icon
Flexbox, Part 2 Chevron down icon Chevron up icon
Wrapping Up Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.3
(3 Ratings)
5 star 33.3%
4 star 33.3%
3 star 0%
2 star 0%
1 star 33.3%
S. A. K. Dec 15, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Full disclosure that I did receive a copy of this book free of charge in order to provide a review. To help the review reader get some perspective on where I am coming to this book from, I have been in frontend development for some time, and have read through many guides, resources, and a lot of documentation for work and side projects, so while there is much I know, there are also some areas where I certainly could improve. That being said, I tried to look at this book with a few specific questions in mind and I tried to take into account others' perspectives by focusing on the following questions as I read through:1) How well does this book cover important CSS topics?2) How well are the topics explained to someone who is new?3) How would this work for someone who knows CSS, but wants a good reference for new material as devices and standards evolve?1) I chose to focus on a few sections where I feel especially knowledgeable as well as a few where I felt less so to try to answer this. One important thing to note is that Rich has done a great job of using a realistic, project-based approach to pulling CSS concepts together. If you follow through his book, you build a site alongside Rich that has many, if not all, of the major CSS properties of most projects you'll encounter in modern web development. Topics such as building for retina displays on modern devices, flexbox, CSS3 transitions and animations is crucial to today's UIs and Rich ensures he covers all of these and much more. At each stage he provides an explanation of why we're doing what we're doing, and what the impact is on the user. Consistently, he brings into play performance considerations and accessibility -- also two very important themes in web development today that one can no longer afford to overlook. I am genuinely impressed by how the breadth and depth here.2) I think one of my favorite things about Rich's writing is how accessible and friendly it is to the user. Reading/coding along you hear the author's voice and feel as though you're sitting and having Rich walk you through a process, not like you're reading some opaque documentation. I think this is great for anyone just dipping their toes into CSS, because it can be very intimidating and because technology evolves so quickly in this sphere, it can be hard to know what works in modern development. Rich does a great job of making the journey comfortable and addressing the concerns that a beginner might have, and might not know s/he should have (i.e. accessibility, responsiveness, browser considerations), without piling too much onto the user. The author is trying to teach you and preempt your questions with clear and concise explanations, not just list off standards or try to get you to memorize things. Rich works hard to make the reader connect concepts and I think he does an excellent job.3) This is probably the piece of the review that I can address most easily because it applies directly to me as a frontend dev who considers himself pretty knowledgeable and capable. I loved that I could read any section of Mastering CSS and pick up one or two new things -- sometimes small, sometimes not, but always interesting and helpful. I spend a lot of time on frontend development and I have read many articles, books, etc. -- it was really refreshing to get the depth that Rich provides, and to be able to get it delivered so concisely. His explanation of how retina displays work and how to ensure a great user experience with images that support their strengths was very clear and one of those "oh wow, that's awesome" moments for me. Those are the moments that I think most devs love to come across and there were many instances where Rich provided additional detailed knowledge that gave me those moments. Of course, I'll continue to use many different sources of documentation (some of which Rich provides in his notes on resources for the user), but this is definitely added to my repertoire.Overall I think Rich does exactly what he sets out to do here, and I think he does it well. Again, I did receive a free copy in order to write this review, but consider this my recommendation when comparing Mastering CSS to several other books and authors I've read on the topic. If you absorbed everything Rich wrote in this book, you would be able to tackle the vast majority of CSS & CSS3 concerns that frontend developers encounter.
Amazon Verified review Amazon
Pratik Jan 08, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This book is suitable for beginners diving into web design. The good thing about this book is that it does not assume any prior knowledge of CSS from you. The only prerequisite is to take your time to do practice and follow along all the examples. It begins from very simple example and that same example carries through the entire book while it teaches more detailed and complex concepts gradually. Before you know, you will have a fairly good understanding of CSS3, Responsive Web Design and some of the advanced concepts such as flexbox.On the flip side, I really wish author would have added couple of appendix on different CSS selectors and CSS specificity. That would server as a reference guide to at my desk and I could refer to them as and when needed.
Amazon Verified review Amazon
Christopher Allen-Poole Apr 17, 2018
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
There are a number of grammatical errors, some of the advice is outdated, other advice is just plain wrong. Much of the book is geared towards a novice, which might forgive some of the statements, but other statements are laughably wrong.- He calls using ID's and class names "renaming" elements. Renaming an element is changing a div to an article. What he's doing is changing the selector or specificity.- He references pseudo classes without explaining what they are (there is a vague reference to how they're used three chapters after he uses the first one).- He talks about IE7. That's not a thing anymore.- He confuses convention (calling things clearfix) with purpose (clearing CSS float property).- He advocates non-semantic CSS as a solution to the problem of non-semantic HTML- He (arguably) conflates anchors and buttons- The specificity "points" concept does not work the way he says. If you have eleven CSS classes in a selector that will not override one ID. (He does clarify this about two chapters after introducing the idea, but he's been using incorrect nomenclature the entire time.)
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela