Home arrow Style Sheets arrow Page 3 - CSS: Working with Text
STYLE SHEETS

CSS: Working with Text


In our last article we left off discussing backgrounds in CSS. We also briefly touched upon working with text, with a promise that I would continue the discussion here. Text is still one of the most important parts of a website, so be prepared to get down to some serious work.

Author Info:
By: James Payne
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
March 10, 2008
TABLE OF CONTENTS:
  1. · CSS: Working with Text
  2. · How to Set the Background Color of Text or Highlight the Text
  3. · You Seem So Distant
  4. · How To Align Your Text
  5. · Indenting Text

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
CSS: Working with Text - You Seem So Distant
(Page 3 of 5 )

You can set the distance between characters, allowing for closer characters or characters that are spaced further apart, using letter-spacing:

<html>

<head>

<style type="text/css">

h1 {letter-spacing: -5px}

p.whoops {letter-spacing: 0.5cm}

</style>

</head>

<body>

<h1>Text that is smooshed together</h1>

<p class="whoops">Text that is letting it all hang out</p>

<p>Normal text</p>

</body>

</html>


Behold the result!

 

  I Just Need Some Space!

Similarly you can modify the space in between lines as well using line-height. Here's a sample:

<html>

<head>

<style type="text/css">

p.smooshed {line-height: 90%}

p.spreadout {line-height: 200%}

</style>

</head>

<body>

<p>

Hey, everything is looking just fine and dandy here. Yeap, plenty of space here. No overcrowding. I can stretch out. Spread the legs a little. Lay back and relax.</p>

<p class="smooshed">Hey uhh....I don't feel so well. Like the walls are starting to close in man. I need air! I need space! Feeling a little cramped...go to your happy place, go to your happy place...</p>

<p class="spreadout">

What? Do I stink or something? I mean, why are all you sentences spread out so far. Do I need a breath meant. Is it my shoes? I showered just the other day. What gives? Where you guys going? GET BACK HERE!</p>

</body>

</html>

And again, for your viewing pleasure:

Increasing the White Space Between Words

In this example, we will increase the white space in between words using word-spacing:

<html>

<head>

<style type="text/css">

p

{

word-spacing: 30px

}

p.monkey

{

word-spacing: -10px

}

</style>

</head>

<body>

<p>

This is what happens when two pieces of text collide:

</p>

<p class="monkey">Wow look at how close we are</p>

</body>

</html>

As you can see when you test your code, the spacing of the first paragraph is spread out pretty far, while the spacing of the p.monkey paragraph is smooshed together.


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials