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

Home > Articles > Web Design & Development > CSS

Elements of CSS

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Attribute-Value Pairs

As you saw in Listing 1, styles are defined through attribute-value pairs, separated by a colon character. The attribute is a keyword that tells the browser what characteristic of the specific element to work with. The value specifies what the browser is to do with this characteristic.

The standard generic form of a style definition is shown in the following code:

selector {
 attribute  : value;
}

The selector in a style definition is an identifier. It can be an HTML tag, a class name, or the ID of an individual element. The Web browser uses the selector to bind the style with the specified element or elements when it displays the content. CSS defines dozens of attributes that can be manipulated. Table 1 describes a few of the most common.

Table 1 Sample CSS Style Attributes

Attribute

Description

font-family

Use a specified font, such as Arial

font-size

Use a given size, such as 14 points or 20 pixels

font-weight

Display in normal, bold, or light face

font-style

Display in normal or italics

text-decoration

Use text styles such as underline and strike-through

color

Use a foreground color as a constant (such as White) or an RGB value code (such as #A0A0A0)

left

Position the element from the left edge

top

Position the element from the top edge


  • + Share This
  • 🔖 Save To Your Account