Fluid typography for responsive websites

Responsive design is a very popular topic nowadays, and currently most designers are adopting this new concept in web design. A responsive layout includes both flexible grids and images able to adapt to the screen’s width.
But what about typography? Shouldn’t font size automatically adjust to different devices and resolutions too? This article aims to show how to achieve fluid type, making your site even more flexible.

Using media queries

One way is to adopt an adaptive approach, setting breakpoints depending on the device width using media queries. For example, setting font size headings to 18px for 480 pixels layouts, and 32px to a range width of 980 pixels.

This option works well if your website is mainly text. But when other kind of content like images and video come into play, and we want to take advantage of multi-column layouts, a fully flexible always take brighter results.
Browser width and typographic length should be proportional in some responsive elements. When using a smaller device, there is less space available for content and fewer words hold in a single line.

Responsive viewport units for fully fluid type

CSS3 introduced some new kind of typographic units: viewport sized typography.
Viewport-percentage units are:

vw stands for viewport width
vh stands for viewport height
vmin equal to the smaller of ‘vw’ or ‘vh’
vmax equal to the larger of ‘vw’ or ‘vh’

W3C How do viewport-percentage units work? Viewport-percentage lengths are relative to the size of the initial containing block, i.e., the container element of the text. When the height or width of the initial containing block is changed, they are scaled accordingly.

Similar results with percentages or em units are achievable, but what makes these so promising is they eliminate the dependency on parent elements and instead allow sizing purely based on the viewport size.

The vw unit (viewport width) is equal to 1/100th or 1% of the width of the viewport. In the example below, if the width of the viewport is 1000px, the font size of the h1 will be 40px.

Doing some math, it’s clear how it works: 4×1000/100 = 40

Shrinking the browser window to 480px wide, the width of the element would resize with it to 19px wide (4×480/100 = 19.2).

Browser support
Currently, these units are only fully supported in Chrome 26+, Firefox11+ and Opera15. To follow-up the evolution of this units, visit this site.



FitText is a jQuery plugin that inflates type to fill its container, creating a similar effect to using viewport-percentage units. No matter what the window size, text will go full width. It is more commonly used on headings, but it can be used through any text element of your DOM.
FitText is one utility that’s grown in popularity, making flexible display type much more accessible.


View FitText source code

Visit FitText demo site

How to use
FitText is a JavaScript file that can be added to your js website folder. In your html file include calls to jQuery and jquery.fittext.js file.
Set up the fitText function to apply to selected elements (h1 and h2 in the following example) and you’re done.

Configurable options
There are some options available in case we want the resize effect to be abrupt or softer – by adjusting the compressor:

We can also set a font-size range to limit the element’s resizing:

The above means that our heading will be displayed at least at 16px – on smaller devices, and it’ll plump until 32px, which is the font-size displayed on bigger desktops.

Here is a quick and simple example:

Container was set to 80% width and any font size was defined to those three text elements.
I decided to set a maximum value of 16px to the paragraph, as I don’t want it get big as headings. Using a higher compressor value results in a smaller font-size. As smaller compressor value is applied, the bigger the resulting font-size value.
The final result:


The algorithm behind
FitTex does on the fly font-size calculation. Uses the width of the element and a configurable JavaScript argument (the compressor) to scale text down to smaller widths – items are resized based on their width divided by the compressor value * 10.
In case maxFontsize and minFontSize variables are set, the font will never be resized over and above those values, respectively.


The BigText jQuery plugin automatically sizes text to fit inside its parent element. BigText is similar to FitText in that it scales text to fit a certain width. The difference between both plugins is that BigText is used to achieve vertical alignment of multiple lines of text. This plugin also works in editable text areas. So that the font resizes as the user types his text.

View BigText source code

Visit BigText demo site

How to use
The BigText jQuery plugin takes a single element and sizes the text inside of its child div’s to fit the width of the parent element, as we can see in this example:

Now, apply the BigText function – call jQuery and BigText script file is also needed.


The algorithm behind
Sizes text automatically from a base up to fit the element width, regardless of initial font size.


Following closely along both option we saw before, SlabText makes it possible to easily create big, bold and 100% fluid headlines for responsive websites.
SlabText might look similar to BigText, but there’s one important difference: BigText uses a constant number of lines while SlabText uses a variable number of lines. Taking a longer title marked h1, SlabText will split it in rows.

View SlabText source code

How to use
Set up SlabText function to h1 elements and prevent slabtext the headers if the viewport is under 320px:

It’s also possible to use Javascript to inject elements into the headline before calling the plugin, keeping the markup cleaner.


The algorithm behind
SlabText script splits headlines into rows before resizing each row to fill the available horizontal space. The ideal number of characters to set on each row is calculated by dividing the available width by the pixel font-size – the script then uses this ideal character count to split the headline into word combinations that are displayed as separate rows of text.

Whatever the method that fits you, make sure you’re offering a pleasant reading. That’s the main point.

Update! If you want to create full fluid type throughout your website, you should have a look at FlowType.


  1. an August 5, 2013 at 3:55 pm

    Why don’t you use em?

    1. Beatriz Oliveira August 5, 2013 at 4:50 pm

      In fact using “em” units only guarantees that type gets proportionally larger in relation to its parent element, but not relative to the size of the browser window.
      “em” by itself will not help achieve fluid type, at best you can do it along with media queries.

  2. Franklin Davis August 5, 2013 at 6:16 pm

    Thanks for a very informative, well written and documented article on responsive text. Its something I don’t see covered like responsive pages and images.

    More please!

  3. mobile app design October 30, 2013 at 12:50 am

    Hi there! Quick question that’s completely off topic.

    Do you know how to make your site mobile friendly?
    My site looks weird when browsing from my apple iphone.
    I’m trying to find a theme or plugin that might be able to resolve this problem.
    If you have any suggestions, please share. Thank you!

  4. […] artigo Fluid Typography for Responsive Websites, são feitas considerações (e mostrados exemplos de código) para temas […]

  5. Sarah | IT Solutions June 17, 2014 at 1:49 pm

    Thank you for this great post! Responsive design is one of those things that users don’t really appreciate until they don’t have it. We are still debating between one single responsive design for our new site rebuild or building a separate mobile site. (I’m leaning responsive.)


Add a comment

Captcha * Time limit is exhausted. Please reload CAPTCHA.