Style Sheets
  Home arrow Style Sheets arrow Page 3 - CSS: Working with Text
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

CSS: Working with Text
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-03-10

    Table of Contents:
  • CSS: Working with Text
  • How to Set the Background Color of Text or Highlight the Text
  • You Seem So Distant
  • How To Align Your Text
  • Indenting Text

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    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.

    More Style Sheets Articles
    More By James Payne


       · Thanks for stopping by to read my article on CSS Text. In this episode we discuss...
     

    STYLE SHEETS ARTICLES

    - Creating Hybrid Web Page Layouts with Negati...
    - Creating Three-Column Web Page Layous with N...
    - Swapping Column Positions in Web Page Layout...
    - Creating Web Page Layouts with Negative Marg...
    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification
    - CSS: Dimensions
    - CSS: Margins and Padding
    - CSS: Crossing the Border






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT