[Top]
More advice for the full screen mode.
   
Sivut toimivat riittävän hyvin MS IE 4.0+, Opera 5.x+, Netscape 6.0+/ vast. Mozilla ja Konqueror 3.x selaimilla. Yleisesti ottaen sivut toimivat parhaiten uusimmilla Opera selaimilla. Sivujen toimivuus vanhemmissa selaimissa on heikko, erityisesti Netscape 4.x kohdalla.

I list below all topic groups, which I have done according to subjects, which they handle. You can return to this topic group by using this menu and the link Table of topic groups on the top of the each page.
 
 
Search:
[Help]
Table of topic groupsFront page of CSS-guideGuide pages4. What are selectors, classes and id-attributes > Class selector, attribute selectors and id selectors (section 2/4)

Class selector, attribute selectors and id selectors

Topics

Common about class, attribute and id selectors

The matching criterion can be specified by using class and id (= identification) attributes and corresponding selectors: class selector or id selector. According to the CSS2 specification the names inside class and id attributes work as identifiers to elements.

The class selector is designed to many elements in the same document. The basic idea of using class selectors is to give the possibility to avoid the limitation of element type identifiers (element names). Using class selectors you can create as many "new elements" as you need.

Class and id selectors (like attribute What are selectors, classes and id-attributes, which I handle later) have higher weight as bare element type selectors. According to the HTML specification the name of the id attribute should be document-wide unique. The id attribute has been called also as the fragment identifier. In principle an id-attribute works as as an unique identifier of some fragment of a web page.

It is however remarkable that CSS-capable browsers accept in CSS the same value of the id-attribute in several places in a document. In practise id selectors could be used (against HTML-specifications) in several places in the same document together with class selectors. In this case classes would define common properties and an id selectors would specify exceptional properties. Indeed the problem is that if documents are intended to check with some validator services, they complain errors. The same result can however be achieved by using for the same element several classes (I give an example further).

  • The name must start with a normal letter (a-z,A-Z). Accepting the underscore (_) has been afterward added into CSS2.
W3C: Errata in REC-CSS2-19980512.
  • You can use also number + hyphen, but you can't start with them.
  • Names are case-insensitive in HTML and case-sensitive in XML.
  • If you want to use special character, you must put the escape character \ (backslash) before them like w\?. In theory it is also possible to use ISO 10646 characters 161 and above as a numeric code. It is possible to use character references inside style attributes (like style="voice-family: D&#252"), but these don't work in external files or inside the element STYLE (they need escaped characters with backslashes).

Browser-specific notes:

  1. Browsers accept illegal names. MS IE 5.x for Windows accepts them most. This matter has been fixed in MS IE 6.0 for Windows in the standard-compliant mode[S]. Also most Netscape and Opera browsers accept illegal names but less than MS IE 5.x for Windows. I have a a model page[S][Pw]in order to test this matter.

  2. Some browsers handle always the values of the class as case-sensitive, but some browsers don't. Use is rules, which refer class or id attributes in name the same cases, which are in the actual documents.

  3. I don't recommend to use any special character, because according my tests they work (at least partial) in Netscape 6.x+ and MS IE 6.0 Windows browsers.

Microsoft: CSS Enhancements in Internet Explorer 6 Public Preview.

[Top]