You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-25Lines changed: 23 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,34 +7,32 @@ We'll start with some really basic markup:
7
7
<h1 class="fancy_title">Some Title</h1>
8
8
9
9
After including jQuery, [download and include the minified version of Lettering.js](http://github.com/davatron5000/Lettering.js/downloads), then a script block with the magical `.lettering()` method:
The resulting code will churn your `.fancy_title` and output the following:
20
20
21
21
<h1 class="fancy_title">
22
-
<span class="char1 char-S">S</span>
23
-
<span class="char2 char-o">o</span>
24
-
<span class="char3 char-m">m</span>
25
-
<span class="char4 char-e">e</span>
26
-
<span class="char5 char-32"> </span>
27
-
<span class="char6 char-T">T</span>
28
-
<span class="char7 char-i">i</span>
29
-
<span class="char8 char-t">t</span>
30
-
<span class="char9 char-l">l</span>
31
-
<span class="char10 char-e">e</span>
22
+
<span class="char1">S</span>
23
+
<span class="char2">o</span>
24
+
<span class="char3">m</span>
25
+
<span class="char4">e</span>
26
+
<span class="char5"></span>
27
+
<span class="char6">T</span>
28
+
<span class="char7">i</span>
29
+
<span class="char8">t</span>
30
+
<span class="char9">l</span>
31
+
<span class="char10">e</span>
32
32
</h1>
33
33
34
34
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.
35
35
36
-
You get further control from classes based on the actual letter for character styling. As you can see in the example above `.charS` allows you to style the letter `s`. __Please Note:__ class names are case-insensitive.
37
-
38
36
As you can imagine, it would be a pain in the ass to have all those `spans` littering your markup and a nightmare to maintain. If the client came by the next day and said that the SEO Expert demands that you have to change the title to "Cool Title", it'd just be a matter of changing the original clean markup to:
39
37
40
38
<h1 class="fancy_title">Cool Title</h1>
@@ -50,17 +48,17 @@ Here's an example of the `.lettering('words')` method:
50
48
51
49
<script>
52
50
$(document).ready(function() {
53
-
$(".word_split").lettering('words');
51
+
$(".word_split").lettering('words');
54
52
});
55
53
</script>
56
54
57
55
Which will generate:
58
56
59
57
<p class="word_split">
60
-
<span class="word1 word-Don39t">Don't</span>
61
-
<span class="word2 word-break">break</span>
62
-
<span class="word3 word-my">my</span>
63
-
<span class="word4 word-heart46">heart.</span>
58
+
<span class="word1">Don't</span>
59
+
<span class="word2">break</span>
60
+
<span class="word3">my</span>
61
+
<span class="word4">heart.</span>
64
62
</p>
65
63
66
64
You can then style each word using the `.word#` class.
@@ -72,16 +70,16 @@ Once word wrapping was complete, we noticed the need for yet another method, one
As expected it uses the `.line#` ordinal pattern. You'll also notice the `<br>`'s have been destructively ripped out. In your CSS, you'll want to declare something like `.line_split span { display:block; }` if you need them to behave as a `<br>` element.
@@ -102,4 +100,4 @@ As with any kind of Javascript, have a fall back plan in case the user doesn't h
102
100
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 experiences a [FOUT (Flash of Unstyled Text)](http://paulirish.com/2009/fighting-the-font-face-fout/) 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.
103
101
104
102
## Download, Fork, Commit, Please.
105
-
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.
103
+
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.
# Lettering.js, a jQuery plugin for radical Web Typography
2
-
We developed a lightweight, easy to use Javascript `span` injector for radical Web Typography, we're calling it "Lettering Dot JS", and we're releasing it today for free over on Github. Let me demo it for you: `</stevejobs>`
3
-
4
-
## Individual Letter Control with Lettering.js
5
-
We'll start with some really basic markup:
6
-
7
-
<h1class="fancy_title">Some Title</h1>
8
-
9
-
After including jQuery, [download and include the minified version of Lettering.js](http://github.com/davatron5000/Lettering.js/downloads), then a script block with the magical `.lettering()` method:
The resulting code will churn your `.fancy_title` and output the following:
20
-
21
-
<h1class="fancy_title">
22
-
<spanclass="char1">S</span>
23
-
<spanclass="char2">o</span>
24
-
<spanclass="char3">m</span>
25
-
<spanclass="char4">e</span>
26
-
<spanclass="char5"></span>
27
-
<spanclass="char6">T</span>
28
-
<spanclass="char7">i</span>
29
-
<spanclass="char8">t</span>
30
-
<spanclass="char9">l</span>
31
-
<spanclass="char10">e</span>
32
-
</h1>
33
-
34
-
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.
35
-
36
-
As you can imagine, it would be a pain in the ass to have all those `spans` littering your markup and a nightmare to maintain. If the client came by the next day and said that the SEO Expert demands that you have to change the title to "Cool Title", it'd just be a matter of changing the original clean markup to:
37
-
38
-
<h1class="fancy_title">Cool Title</h1>
39
-
40
-
It also plays nicely with CMSs like WordPress or Expression Engine and art direction plugins.
41
-
42
-
## Wrap Words with Lettering.js
43
-
Once we developed this e-solution and played with it, we found it useful enough to broaden the scope so that we could break apart and wrap words in a sentence in a span tag.
44
-
45
-
Here's an example of the `.lettering('words')` method:
You can then style each word using the `.word#` class.
65
-
66
-
## Wrap Lines with Lettering.js
67
-
Once word wrapping was complete, we noticed the need for yet another method, one that would break lines up mid-sentence. We struggled for a semantic way to do this, but then remembered `<br>` tag which a semantic way to say "break this line". Similar to the above examples where lines of text are broken up by either non-breaking spaces or individual letters, the `lettering('lines')` method will create breakpoints at `<br>` tags:
As expected it uses the `.line#` ordinal pattern. You'll also notice the `<br>`'s have been destructively ripped out. In your CSS, you'll want to declare something like `.line_split span { display:block; }` if you need them to behave as a `<br>` element.
86
-
87
-
## Best Practices & Kerning
88
-
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.
89
-
90
-
### Best Practices
91
-
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.
92
-
93
-
### Kern Well
94
-
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.
95
-
96
-
### Non-Javascript Fallback
97
-
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](http://github.com/davatron5000/Lettering.js/downloads)
98
-
99
-
### Performance Anti-Pattern
100
-
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 experiences a [FOUT (Flash of Unstyled Text)](http://paulirish.com/2009/fighting-the-font-face-fout/) 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.
101
-
102
-
## Download, Fork, Commit, Please.
103
-
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.
0 commit comments