Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Responsive Typography

Clarissa Peterson
February 18, 2015

Responsive Typography

Your content is the most important feature of your website, so it's important to make sure that the text looks good and is easy to read no matter what device type or screen size it's being viewed on. One size does not fit all when it comes to typography, but you can use media queries to adjust type qualities such as size, line height, column width, margins, hyphenation, and even typeface depending on the viewport size. Learn how you can use CSS to apply design rules that will make your typography look better and perform better across devices. You'll also find out how typography affects the loading time of your website, and what you can do to improve performance.

Presented in 2015 at ConFoo. Presented in 2014 at WebVisions Chicago, Blend Conference, Frontend Conference Zurich, Refresh Ottawa, Mobile+Web Dev Conference, STC Summit, Bmoresponsive, ConvergeSE, and Girl Geeks Montreal.

Clarissa Peterson

February 18, 2015
Tweet

More Decks by Clarissa Peterson

Other Decks in Design

Transcript

  1. h1 { font-size: 3em; } h2 { font-size: 2em; }

    h3 { font-size: 1.5em; } p { font-size: 1em; }
  2. <p>This is 1 em.</p> <div>This is 2 ems <span>(and 1.5

    ems) </span>.</div> p { font-size: 1em; } div { font-size: 2em; } span { font-size: 1.5em; }
  3. <p>This is 1 em.</p> <div>This is 2 ems <span>(and 1.5

    ems) </span>.</div> p { font-size: 1em; } div { font-size: 2em; } span { font-size: 1.5em; }
  4. p { line-height: 1.3 } @media only screen and (min-width:

    30em) { p { line-height: 1.4 } } @media only screen and (min-width: 60em) { p { line-height: 1.5 } }
  5. .testing { color: #f00; } <p>These stories are true. Although

    I have left <span class=”testing”>the strict line of historical</span> truth in many places, the animals in this book were all real characters.</p>
  6. .testing { color: #f00; } <p>These stories are true. Although

    I have left <span class=”testing”>the strict line of historical</span> truth in many places, the animals in this book were all real characters.</p>
  7. @media only screen and (min-width:48em) { article { font-size: 1.1em;

    } article p { line-height: 1.4; margin: 1.4em auto; } }
  8. @media only screen and (min-width:60em) { article { font-size: 1.2em;

    } article p { line-height: 1.5; margin: 1.5em auto; } }
  9. #intro { font-size: 1em; font-family: Helvetica, sans-serif; } @media only

    screen and (min-width:30em) { #intro { font-size: 1.2em; font-family: Populaire, sans-serif; text-transform: uppercase; } }
  10. @font-face { font-family: ExampleFont; src: url('ExampleFont.eot'); src: local('Example Font'), url('ExampleFont.eot?#iefix')

    format('embedded-opentype'), url('ExampleFont.woff') format('woff'), url('ExampleFont.ttf') format('truetype'), url('ExampleFont.svg') format('svg'); font-style: normal; font-weight: 400; }
  11. @font-face { font-family: ExampleFont; src: url('ExampleFont.eot'); src: local('Example Font'), url('ExampleFont.eot?#iefix')

    format('embedded-opentype'), url('ExampleFont.woff') format('woff'), url('ExampleFont.ttf') format('truetype'), url('ExampleFont.svg') format('svg'); font-style: normal; font-weight: 400; }
  12. @font-face { font-family: ExampleFont; src: url('ExampleFont.eot'); src: local('Example Font'), url('ExampleFont.eot?#iefix')

    format('embedded-opentype'), url('ExampleFont.woff') format('woff'), url('ExampleFont.ttf') format('truetype'), url('ExampleFont.svg') format('svg'); font-style: normal; font-weight: 400; }
  13. @font-face { font-family: ExampleFont; src: url('ExampleFont.eot'); } p { font-family:

    Arial, sans-serif; } @media only screen and (min-width: 30em) { p { font-family: ExampleFont, Arial, sans-serif; } }