5. Syntax Rules of WCSS

The syntax rules of WCSS are not difficult to learn. A WCSS statement is consisted of a selector, a property, and a property value. The selector specifies the element(s) affected by the style rule. Typically, the selector is the XHTML MP element that you want to apply the style to (there are other types of selectors and they will be covered later at "Different Types of Selectors"). The property specifies the style you want to set. The property value is the value that you assign to a certain property. The syntax of a WAP CSS statement is like this:

selector {property: property_value}

This is an example of a WAP CSS statement:

p {text-align: right}

The above style statement tells the WAP browser to align the text enclosed within all <p></p> tags to the right horizontally.

Multiple properties are separated with a semicolon. The syntax is like this:

selector {property1: property_value1; property2: property_value2; ... propertyN: property_valueN}

Below is another WCSS example. The style statement tells the WAP browser to align the text enclosed within all <p></p> tags to the right and change the text color to blue.

p {text-align: right; color: blue}

Specifying more than one selector is allowed. A comma is used to separate the selectors. The syntax is like this:

selector1, selector2, ... selectorN {property1: property_value1}

Let's have a look at another WCSS example. The style statement below will cause the text enclosed in all <p></p> and <h1></h1> tag pairs to be aligned to the right horizontally and shown in blue color.

p, h1 {text-align: right; color: blue}

6. Comments in WCSS

In WCSS, comments are enclosed within /* and */. WAP browsers ignore all comments. This example demonstrates the use of comments in WCSS:

p {
  /* A single line comment in WAP CSS */
  /* A multi-line comment
     in WAP CSS */
  text-align: right; /* A comment can be placed at the end of a line. */
  color: blue

Previous Page Page 3 of 39 Next Page

Feedback Form (ExpandCollapse)

What do you think about this web page?

(Optional) Please provide us more details. For example, suppose you select option 2 above, can you tell us specifically what information is missing? You can also suggest anything that can help us improve this web page.

(Optional) Your name:

(Optional) Your email address:

Please enter again to confirm:

Due to the amount of messages we received, we may not be able to reply to all messages.

A button for going back to the top of this page