• Stars
    star
    5,393
  • Rank 7,254 (Top 0.2 %)
  • Language
    JavaScript
  • Created over 13 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A lightweight, easy to use Javascript <span> injector for radical Web Typography

Lettering.js, a jQuery plugin for radical Web Typography

CDNJS

We developed a lightweight, easy to use Javascript span injector for radical Web Typography, we're calling it "lettering-jay-ess", and we're releasing it today for free over on Github. Let me demo it for you: </stevejobs>

Individual Letter Control with Lettering.js

We'll start with some really basic markup:

<h1 class="fancy_title">Some Title</h1>

After including jQuery 1.6.2+, download and include the minified version of Lettering.js, then a script block with the magical .lettering() method:

<script>
	  $(document).ready(function() {
	Β Β   $(".fancy_title").lettering();
	  });
</script>

The resulting code will churn your .fancy_title and output the following:

<h1 class="fancy_title">
  <span class="char1">S</span>
  <span class="char2">o</span>
  <span class="char3">m</span>
  <span class="char4">e</span>
  <span class="char5"></span>
  <span class="char6">T</span>
  <span class="char7">i</span>
  <span class="char8">t</span>
  <span class="char9">l</span>
  <span class="char10">e</span>
</h1>

Magical. Now the text is easy to manipulate in your CSS using an ordinal .char# pattern. This plugin assumes basic counting skills, but it's a pretty fast and easy way to get control over every letter.

Letters, words, lines, and more!

There you have it, but Lettering.js does even more! Lettering.js has the ability to split words and lines as well. If you want more information on how you can get radical with text, read the Lettering.js Wiki:

https://github.com/davatron5000/Lettering.js/wiki

Best Practices

We've found this to be a pretty quick and elegant solution to create typographical CSS3 posters. It's also a great solution for really custom type headings, while keeping the text selectable. Be smart and use sparingly. You'll probably break your browser if you try to wrap every letter on your page in a span tag, so don't do that. Look to use this in your Headings, Blockquotes, Asides, etc.

Kern Well

If you're going through the trouble to load a fancy font and that word or phrase is the largest on the site, then it's important for it to be kerned well. With Lettering.js, kerning is a breeze. You can simply use $("#id-of-what-i-want-to-kern").lettering(); and then on each .char#, you can set relative position or left/right margin. Works like a charm.

Accessibility

Lettering.js is now accessible by default. It uses an aria-label on the parent element and aria-hidden on each of the children to prevent screenreaders from pausing while reading each individual characters or words.

Non-Javascript Fallback

As with any kind of Javascript, have a fall back plan in case the user doesn't have javascript enabled. The bottom line is up to you, my bottom line would be "legible and on the screen". Also, use lettering.min.js Download the Minified Version of Lettering.js here

Performance Anti-Pattern

Web performance patterns advise that you put Javascripts at the bottom of your page before your </body> tag. There is an unfortunate side effect where you may experience a FOUT (Flash of Unstyled Text) when you're manipulating your text after the DOM has loaded. Unfortunately, we found the best solution to avoid/minimize the FOUT caused by this plugin is to put your scripts (jQuery, Lettering.js) in the document <head>. On the one hand, your page will load slower. On the other hand, a flash/restyling makes your site feel slow. Users might ultimately feel the site is faster if they don't see the FOUT.

Download, Fork, Commit, Please.

We really want Lettering.js to be a quality helper for web typography. If you have any feedback or suggestions, please leave those over on the Github. We're excited about typography on the web and want to help make it print quality.

More Repositories

1

FitText.js

A jQuery plugin for inflating web type
HTML
6,769
star
2

FitVids.js

A lightweight, easy-to-use jQuery plugin for fluid width video embeds.
HTML
4,769
star
3

awesome-standalones

A curated list of awesome framework-agnostic standalone web components
1,183
star
4

Foldy960

A responsive version of the 960 grid, the Pvel way!
CSS
483
star
5

TimeJump

TimeJump – Deep-links for Podcasts
JavaScript
348
star
6

can-i-subsystem-it

313
star
7

deCSS3

A lil' bookmarklet that will strip out your CSS3 rules and show you how gracefully you're degrading.
JavaScript
311
star
8

podcast-player

An audio web component for podcasts
117
star
9

a11y-nutrition-cards

Nutrition Cards for Accessible Components
HTML
89
star
10

htmlwithsuperpowers

A guidebook to Web Components
86
star
11

Better-Art-Direction

A fork of the incredible Art Direction plugin by NoΓ«l Jackson (http://noel.io).
PHP
77
star
12

fitWeird

A window monitor bookmarklet.
JavaScript
63
star
13

WP-Dribbble

A wordpress plugin and widget that pulls in your latest Dribbble shots.
PHP
54
star
14

fit-vids

Web Component version of FitVids from the creator of FitVids
JavaScript
39
star
15

Borkers

HTML5 Boilerplate + Starkers = Borkers! A starter theme.
PHP
22
star
16

humans-vs-robots

An unpacked chrome extension for Github
JavaScript
19
star
17

wobbly-box

A web component for drawing wobbly boxes
JavaScript
16
star
18

alpha-paintlet

A CSS Paint worklet that converts alpha's your bg-color based on some variables.
HTML
14
star
19

NodebotUI

Twitter Bootstrap for Nodebot Interfaces
JavaScript
14
star
20

sortByData

A simple jQuery plugin that lets you sort a collection of elements by any data- attribute you want.
JavaScript
5
star
21

2x

A chrome extension for speedier HTML Media
JavaScript
5
star
22

worker-controller

JavaScript
4
star
23

html-with-superpowers

HTML
4
star
24

htmlwithsuperpowers-deck

Vue
4
star
25

FitGrid

3
star
26

api-screenshot

JavaScript
2
star
27

jekyll-reduced-test-case

Ruby
1
star
28

jekyll-polymer

HTML
1
star
29

davatron5000

1
star
30

12th-Street-Bakery

A non-profit bakery teaching at-risk teens the art and skill of baking.
HTML
1
star
31

begin-graphql-test

Begin app
JavaScript
1
star