Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > CSS

This chapter is from the book

Text Properties

Now that you’ve looked at how to style font properties, it’s time to look at how to style text properties. If you want to indent a paragraph, create a superscript such as the 6 in 106, create more space between each letter of a headline, and many other type formatting tasks, you will use the CSS text properties.

Here are the most useful text-related CSS properties:

  • text-indent
  • letter-spacing
  • word-spacing
  • text-decoration
  • text-align
  • line-height
  • text-transform
  • vertical-align

Text-Indent Property

Values: any length value (positive or negative)

Example: p {text-indent:3em;}

This property sets the start position of the text box in relation to the containing element. By default, that is the top-left corner of the container.

If you set a positive value to the text-indent, then the text moves to the right, creating an indented paragraph (Figure 4.5, example 1).

Figure 4.5

Figure 4.5. These four examples illustrate the text-indent property.

However, if you set a negative value for text-indent, the first line hangs out to the left of the containing element, so make sure that there is a place for it to go. If there’s an element to the left, the hanging text can overlap it, or if it’s close to the edge of the browser window, it is clipped (Figure 4.5, example 2). The way to avoid this problem is always to specify a positive left margin value greater than the specified negative indent. In Figure 4.5 example 2, the negative indent is –1.5 ems, but in Figure 4.5, example 3, there is also a left margin value of 2 ems. Here is how this is written.

Indents can help give text a professionally-styled look and also give the reader clear visual entry points into the text blocks. Remember to set indents and related margins in ems, as I have done here, so that the indent remains proportional to the line length if the user (or you) changes the font size.

Letter-Spacing Property

Values: any length values (positive or negative)

Example: p {letter-spacing:.2em;}

Positive letter-spacing values increase the overall space between letters, while negative values decrease it. Always use relative values such as ems for letter spacing, even if you are setting the font size in pixels, so that the spacing remains proportional if the font size changes. Examples are shown in Figure 4.7. letter-spacing controls tracking, which is the typographical term for the letter spacing applied to all characters in a block of text. This contrasts with kerning, which is the term for adjusting the space between two specific characters.

The default letter spacing of a font appears looser as the text gets larger, so tightening the letter spacing of a headline adds refinement to your Web page. Note the text and headline I tightened in Figure 4.7 only have .05 em (a twentieth of an em) of letter spacing removed from between each character; much more and the letters would start to merge into each other.

Figure 4.7

Figure 4.7. You can see how changing the letter-spacing value changes the look of your text.

Word-Spacing Property

Values: any length values (positive or negative)

Example: p {word-spacing:.2em;}

Word spacing is very similar to letter spacing except, as you might imagine, the space changes between each word rather than between each letter. CSS treats any character or group of characters with white space around them as a word. Second, even more than letter spacing, word spacing can easily be overdone and result in some very hard-to-read text (Figure 4.8).

Figure 4.8

Figure 4.8. Paragraphs and headlines with normal, negative, and positive word spacing.

Text-Decoration Property

Values: underline, overline, line-through, blink, none

Example: .retailprice {text-decoration:line-through;}

These values, with the exception of blink, are displayed in Figure 4.9. blink, which makes text flash on and off, is truly annoying, and should be used sparingly, or better yet, not at all.

Figure 4.9

Figure 4.9. These are the various text-decoration values, but the most useful application is the control of underlining on links.

The primary application of text decoration is controlling the underlining of links. Here’s an example that removes the underlining of links in a navigation bar, where the text is obviously clickable and underlining is just clutter, but adds it back when the user rolls over a link, providing a little tactile feedback.


Text-Align Property

Values: left, right, center, justify

Example: p {text-align:right;}

There are only four values for this property: left, right, center, and justify. The text aligns horizontally within the element. Note that center will also center a smaller fixed-width element or image horizontally within a larger element. Figure 4.10 shows the four possible text-align values in action.

Figure 4.10

Figure 4.10. The four text-align values.

Line-Height Property

Values: any numerical value (value type is optional)

Example: p {line-height:1.5;}

line-height is the CSS equivalent of leading (pronounced like the metal) in the world of print. Leading creates space between the lines of a block of text.

Line height is distributed above and below the text. For example, if you have a font size of 12 pixels and you set the line height to 20 pixels, the browser adds 4 pixels of space above and 4 pixels of space below to achieve the 20 pixel line height.

On a single line of text like a headline, line-height acts like another margin, and large headlines (h1 and h2, for example) have a significant amount of default line height. This is worth remembering, because sometimes you will find that even after removing margins and padding, you still can’t eliminate all the space above and below a headline. To do this you need to reduce the line height also, sometimes to a height less than that of the text, i.e., less than 1.

As shown in Figure 4.11, the simplest way to change this default line height is to use the font shorthand property and write a compound value for both font-size and line-height in one. For example:

Figure 4.11

Figure 4.11. A variation of the standard line height is a simple way to give a distinctive look to your pages.

In this case, the leading is 1.4 times the font size of 1.2 ems. Note that you don’t need any units, such as ems or pixels, specified for the line-height part of the value, just a number. In this case, CSS simply takes the calculated size of whatever number of onscreen pixels 1.2 ems works out to be and multiplies it by 1.4 to arrive at the line height. If you later increase the font size to 1.5 ems, the line height (leading) is still 1.4 times the calculated amount of 1.5 ems. Note if you specify a line height in a fixed unit, such as pixels, and you increase the font size, then the lines of text may start to overlap one another.

Text-Transform Property

Values: none, uppercase, lowercase, capitalize

Example: p {text-transform:capitalize;}

text-transform changes the capitalization of text within an element. You can force a line of text to have initial letters capitalized, all text uppercase, or all text lowercase. Figure 4.12 illustrates these options.

Figure 4.12

Figure 4.12. text-transform lets you add newspaper-style headline formatting to text.

capitalize capitalizes the first letter of every word. This emulates the style of many headlines in ads, newspapers, and magazines, except that a human applying such styling tends to leave the capitalization off minor words such as “of,” “as,” and “and,” as in “Tom and Jerry Go to Vegas.” CSS capitalization simply produces “Tom And Jerry Go To Vegas.”

Vertical-Align Property

Values: any length value, sub, sup, top, middle, bottom

Example: span {vertical-align:60%;}

vertical-align moves text up or down with respect to the baseline, but note that it only affects inline elements. If you want to vertically align a block-level element, you must also set its display property to inline. One of the most common uses is for superscript and subscript numbers in formulas and mathematical expressions, such as x4–y-5 or N3O. It’s also the correct way to style asterisks and other markers within text to indicate footnotes. I don’t like the way most browsers style sub- and superscripts by default—the font size is too large and too high (or low, for subscript) for my liking. A little styling can render better, and more consistent cross-browser, proportions.

Here’s the HTML for this example

and the CSS

While the HTML tags sup and sub create superscript or subscript text automatically, it’s worth using vertical-align and font-size in combination to produce a more pleasing result (Figure 4.13). This covers the font and text properties of CSS. Now let’s look at how fonts can be downloaded into your Web pages.

Figure 4.13

Figure 4.13. Superscripting and subscripting vary the vertical position and size of text.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive:

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020