


























I've always been focused on strong typography when it comes to design. As I've evolved into a front end developer, I still focus a lot on the typography of a project. As I've written about before, if the design is up to me, I even start with setting the paragraph.
However, what can you do to set yourself up for success when it comes to coding a design and it's typography? I've done this - a lot - and I've come to some conclusions.
Some of my guiding principles are:
So what does this look like in an actual project?
$sans-serif: "Source Sans Pro", Helvetica, Verdana, sans-serif;
$serif: Merriweather, Georgia, "Times New Roman", serif;
$mono: "Source Code Pro", Courier, mono;
The above example is from this very website's variables partial. (In my case my third typeface is used for code examples).
$light: 300;
$normal: 400;
$semibold: 500;
$bold: 700;
Style the body element. This is where I typically see other developers missing an opportunity to make their lives easier, so this is really the point of the post. If you apply the paragraph typographic style to your body element, you will save yourself a lot of rework. If you've identified the most common typographic treatment (see Step 1), you can style your <body> element with that treatment. This has three advantages -
Here is what this website's body element looks like:
body {
font-family: $sans-serif;
font-weight: $light;
color: $txt-primary; //color variable set elsewhere
background: $body-bg;
-webkit-text-size-adjust: 100%; //fix for iOS
}
This is usually constrained just to the font-family, font-weight, color, and sometimes line-height declarations. You're not going to want to apply box-model properties to the <body> element.
With this styling in place, you can start changing the style of elements by making use of the font-weight and font-style property, which goes back to the "least amount possible" principle. By relying on those styling switches, governing the overall typeface becomes much easier.
Now, when you want to call in your secondary or accent typeface, you deliberately declare it where needed, and that's it.
h1 {
font-family: $serif;
}
And since you already have your font stacks declared as variables, you can govern that type choice much more easily.
I hope these guidelines and basic steps help you in your next project.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。