It is easy to think that everything will work with mouse clicks on the web. However, many devices support other types of pointing input devices, such as pen/stylus and touch surfaces so we need a way to work with all of them without writing duplicate code. According to MDNhttps://developer.mozilla.org/en-US/docs/Web/API/Pointerevents: > The pointerhttps://developer.mozilla.org/en-US/docs/Web/API/Pointereventspointer is a hardware-agnostic device that can target a specific set of screen coordinates. Having a single event model for pointers can simplify creating Web sites and applications and provide a good user experience regardless of the user's hardware. However, for scenarios when device-specific handling is desired, pointer events...
Reading min, max, and clamp: three logical CSS functions to use todayhttps://web.dev/min-max-clamp/ presented an interesting case for using clamphttps://developer.mozilla.org/en-US/docs/Web/CSS/clamp: Controlling the width of a text-container. In typography books, we're told that text should be between 45 and 75 characters wide. Until I saw the example, I hadn't thought about using clamp in combination with the chhttps://developer.mozilla.org/en-US/docs/Web/CSS/length length unit to express this requirement. In the following code snippet, we tell the browser that we want the width of the article to be 50% of the screen width but no smaller than 45ch or larger than 75ch, regardless of the viewport size....
As documented in CSS values and unitshttps://developer.mozilla.org/en-US/docs/Learn/CSS/Buildingblocks/Valuesandunits there are new or lesser-known units. The first table, taken from MDN, shows the most common / better known to me viewport units | Unit | Relative to | | --- | --- | | vw | 1% of the viewport's width. | | vh | 1% of the viewport's height. | | vmin | 1% of the viewport's smaller dimension. | | vmax | 1% of the viewport's larger dimension. | Most of the time I will limit my use of viewport units to vh and vw. The table below shows a...
There are layouts that are only possible with columns. Thinking about IEEE and ACM paper formats. !Example of a two-column paper for ACM publicationshttps://res.cloudinary.com/dfh6ihzvj/image/upload/cscale,w500/fauto,qauto/acm-paper-template !Example of a paper formatted for IEEE publicationhttps://res.cloudinary.com/dfh6ihzvj/image/upload/cscale,w500/fauto,qauto/ieee-format-paper The biggest difference is that the paper formats are paginated so it's relatively easier to shift from one column to another and from page to page. Because the web is one continuous format, reading columns becomes much harder since we have to scroll to get to the bottom of one column and then scroll to the top to start the next one. If we have small blocks of...
We have many ways of reading content and they will all be different. So how to best optimize font size for reading long-form content online? For this exercise we'll define three sizes for the content: small: to be read at a close distance medium: our default size to be read while sitting on your desk large: to be read farther away than medium or on larger screens For the sake of experimentation I've chosen the following sizes small: 12 points medium: 16 points large: 24 points The idea is that the farther away we are reading from the larger we...
OpenType fonts, both static and variable, make additional features available for developers to use. CSS makes these features available via the font-feature-settings property. Just like with font variations in variable fonts, we can use tools like Wakamaifonduehttps://wakamaifondue.com to see what OpenType features are available since they vary based on the font and to download a stylesheet with all CSS necessary to use the features on your own project. We first set custom properties for each of the available OpenType layout features on the :root pseudo-element. We set them disabled by default so we can enable them for specific elements and...
Variable fonts are an evolution of the OpenType font specification that enables many different variations of a typeface to be loaded from a single file and a single @font-face declaration. The single file would be larger than a single font, but in most cases smaller or about the same size as the 4 you might load for body copy. The advantage in choosing the variable font is that you have access to the entire range of weights, widths, and styles available, rather than being constrained to only the few static font files that you would have loaded separately. You may...
In a previous post, we looked at what font should we choose. Another side of the question is where to get the fonts from. This post will discuss font availability and how to incorporate the fonts into your CSS stylesheets. Variable fonts will not be covered here. They are a large topic and will get their own post later in the series. Generic font families Generic font families are designed as fallback fonts for web font stacks. The idea is that they will map to an existing font on the user's computer so there will be a font to render...
I'm not a type designer and I consider myself adequate as a user of fonts on the web, but I've been around for the full progression of fonts on the web. We will not review the full history of web fonts in this post. If interested you can read the history on Brief History of Webfontshttps://www.typotheque.com/articles/briefhistoryofwebfonts Font selection The first decision we need to make is what font we want to use. It is a deceptively simple question since it is not just a matter of picking up a font that looks nice. I follow this list, taken from Google...
The first area to consider is how we use the space on the page. Because we have different screen sizes and resolutions, we have to be mindful of how we organize the space. Content width One of the biggest issues with working with long-form content is how many characters wider should we go? According to the The Elements of Typographic Style Applied to the Webhttp://webtypography.net/ the optimal measure length of a line is between 45 and 75 characters. We will have problems if the line is too long or too short. According to the Baymard Institutehttps://baymard.com/blog/line-length-readability: > If a line...