Search within TutorialsPark

CSS Class and Id

Basic CSS selectors using class and id .

CSS : Universal Selector ( * )

1. A universal selector ( * ) is a wildcard selector for every HTML tag on the document.

2. Universal selector applies properties to all HTML elements.It is often used as to reset stylesheets or hide stylesheet from IE6.

Example:CSS Universal Selector ( * ).

Give it a TRY! » Note: Universal selector is not supported for IE6.

CSS : Type(or tag) Selectors

1. The CSS Type selector or element selector applies CSS properties to every occurence of the HTML tag on the webpage.

2. This selector enables you make sweeping changes for a particular tag with very little effort.

Example:CSS Type (or tag) Selector

Give it a TRY! » Note: Type selectors are mainly used to define the basic style for the entire website.

CSS : Class Selector

1. To assign same CSS style to more than one element, you can use the CSS class selector.

2. Multiple HTML elements must have the same class attribute inorder to have the same style.

3. It enables you to very specifically target an element on the webpage, regardless of its Tag.

4. To create the selector you must prefix the class name with a period( . ). Eg: .myClass .

Example: CSS Class Selector.

Give it a TRY! » Note:Elements like <div> and <span> with no properties can be assigned a class to create custom HTML tags.

CSS : Id Selector

1. Similar to class, an Id Selector applies the styles to the elements with same Id attribute.

2. The id attribute is used to assign a unique identifier.It can be used only once per page to identify a single element.

3. To create the Selector you must prefix the ID name with a pound or hash(" # "), Eg: #Caution.

Example: CSS Id Selector.

Give it a TRY! » Note: A given element can have both class and id attribute, but must try not to have the same name for them.