How To

How to Define a Style Definition in HTML

Contributor
By eHow Contributing Writer
(1 Ratings)

As a way of making things easier on the web master and thus preventing the need to repeatedly type the same HTML code over and over, HTML's Style syntax allows you to enter HTML code once and have the browser repeat that code in the necessary places.

Difficulty: Moderate
Instructions

Things You'll Need:

  • Plain text editor

    Prepare to Define a Style Definition

  1. Step 1

    Familiarize yourself with a style definition in HTML. A style definition instructs a web browser to render a specific HTML element a certain way every time that HTML element is shown. If for example, a web master wants to portray a string of text in a bold red font but doesn't want to repeatedly re-type the font attributes for every instance of the string, she can define a style for that string instead.

  2. Step 2

    Start by opening your web page in Windows Notepad. If the file size is too large, you can use WordPad instead. You can also use a web design program like Dreamweaver opened in HTML mode.

  3. Define a Style Definition in HTML

  4. Step 1

    Begin the style tag by typing the following code in the header section of the Web page: < STYLE >

  5. Step 2

    Decide which HTML element should always use the same formatting (syntax and attributes). Example:< P >, the "paragraph" tag.

  6. Step 3

    Insert the appropriate style for the HTML element.
    P { color : blue;
    font-size : 12pt;
    font-family : Arial
    }

  7. Step 4

    Close the style tag by typing the following HTML code:< /STYLE >. The end result should resemble the following:
    < STYLE >
    P { color : blue;
    font-size : 12pt;
    font-family : Arial
    }
    < /STYLE > In this example, all the text in each paragraph would default to and display as a blue, 12pt Arial font without having to encase the paragraphs in separate font tags.

Tips & Warnings
  • Make sure to test your HTML pages in several different browsers. As not all browsers interpret HTML code in the same way, you might see discrepancies or even errors. You want to make your code as compatible as possible.

Post a Comment

Post a Comment

Have you done this? Click here to let us know.

I Did This

Related Ads

Internet
Virginia DeBolt,

Meet Virginia DeBolt eHow’s Internet Expert.

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US

Demand Media
eHow_eHow Technology and Electronics