bottom
Great WordTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > WordTips Home > Formatting > Searching for Formatting > Adding Tags to Text

Adding Tags to Text

Summary: The Find and Replace capabilities of Word can be used to add HTML tags to your document text. This is easier to do than it may sound, using the technique outlined in this tip. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)

If you love working in HTML, you know that it is created by simply adding tags to regular text. Tags do nothing more than describe how a browser should display the text. HTML can be created by hand or automatically, by program. You can even use Word to create your HTML for you.

What if you don't want Word to do the HTML automatically, but you want to use Word's tools to help you in your HTML creation? For instance, you might want to search for italicized text within a document and then surround it with the HTML tags that signify the text should be displayed in italics. You can do this by following these steps:

  1. Press Ctrl+H. Word displays the Replace tab of the Find and Replace dialog box.
  2. Click on the More button, if it is available. (Click here to see a related figure.)
  3. With the insertion point in the Find What box, click the Format button and choose Font. Word displays the Find Font dialog box. (Click here to see a related figure.)
  4. In the Font Style list, choose Italic.
  5. Click on OK to dismiss the Find Font dialog box.
  6. In the Replace With box, enter "^&" (without the quote marks). Both and are HTML tags for italics, and ^& is the special code for the Find What text. In other words, you want to replace what you find with what you found, but make sure it is surrounded by the HTML tags for italics.
  7. With the insertion point still in the Replace With box, click the Format button and choose Font to again display the Find Font dialog box.
  8. Scroll down in the Font Style list and choose Not Italic. You want to do this so that when the find and replace operation is done, not only have you added the proper HTML tags, but you are turning off the italics attribute of the found text. This is important so that if you later run the same macro on the same document, you don't get large numbers of nested HTML tags.
  9. Click on OK to dismiss the Find Font dialog box.
  10. Click on Replace All to process the entire document, or use the other buttons in the Find and Replace dialog box to step through the occurrences of italic text one at a time.

The same find and replace technique can be used to add other HTML tags, as desired. For instance, you could add the tags for bold text, and by searching for Bold in step 4, using the proper tags in step 6, and replacing with Not Bold in step 8.

Tip #1904 applies to Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007


Tremendous Table Tips! We often take tables for granted, but Word includes some very powerful ways you can present your tabular data. Discover how to make your tables better, easier to understand, and more effective.
 
Check out WordTips: Terrific Tables today!

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now

Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)