1 Web dev math fundamentals

 

This chapter covers

  • Appreciating the benefits of learning web dev math
  • Understanding the importance of web dev math
  • Learning how math is used in CSS and JavaScript
  • Reviewing the math basics you need to know

When you design or code a website, you might not think of yourself as “doing math,” but there’s likely at least a little mathematics behind most of what you do. Are you using relative units such as em or rem? There’s math behind those units. Are you applying an easing function such as ease-in-out to an animation? There’s math behind that function. Does your JavaScript code call the getBoundingClientRect() method on an element to determine its size and position? There’s math behind that method.

Sure, it’s possible to design and develop websites without giving math more than a cursory thought. And, certainly, whatever math lies underneath a unit such as em or an easing function such as ease-in-out might not matter to you as long as the job gets done. But the whole point of this book is that if you take a bit of time to understand that math, then you’ll find it makes a big difference in the precision and robustness of your web layouts and interfaces. The good news is that you don’t need a graduate degree in math to build better websites. There’s only a little math that you need to know, and none of it is as complex as the CSS and JavaScript that you already know.

1.1 Why bother learning about front-end math

1.2 Why math matters in front-end development

1.2.1 The connection between mathematics and web design

1.2.2 Real-world examples of math in UI/UX

1.2.3 How developers use math in animations, layouts, and interactions

1.3 The role of mathematics in CSS and JavaScript

1.3.1 How CSS uses math

1.3.2 JavaScript’s built-in mathematical capabilities

1.3.3 Comparing CSS and JavaScript math approaches

1.4 The minimum math you need to know

1.4.1 Arithmetic and arithmetic expressions

1.4.2 Algebra

1.4.3 Ratios

1.4.4 Exponents and nth roots

1.4.5 Linear equations

1.4.6 Inequalities and comparison expressions

1.4.7 Geometry

1.4.8 Trigonometry

1.4.9 Coordinate systems

1.5 Summary