Difference between revisions of "Class selector (CSS)"
From Wiki @ Karl Jones dot com
Karl Jones (Talk | contribs) (→See also) |
Karl Jones (Talk | contribs) |
||
Line 1: | Line 1: | ||
In [[CSS]], a '''class selector''' (or '''class style rule''', or '''class style''', etc.) is a [[selector]] which selects zero or more [[HTML element|HTML elements]] based on the elements' [[Class attribute (HTML)|class attribute]]. | In [[CSS]], a '''class selector''' (or '''class style rule''', or '''class style''', etc.) is a [[selector]] which selects zero or more [[HTML element|HTML elements]] based on the elements' [[Class attribute (HTML)|class attribute]]. | ||
+ | |||
+ | It is used in combination with [[Class attribute (HTML)|class attributes]]. | ||
== Example == | == Example == | ||
Line 25: | Line 27: | ||
* [[Bootstrap responsive image]] | * [[Bootstrap responsive image]] | ||
* [[Cascading Style Sheets]] | * [[Cascading Style Sheets]] | ||
+ | * [[Class attribute (HTML)]] | ||
* [[HTML element selector (CSS)]] | * [[HTML element selector (CSS)]] | ||
* [[ID selector (CSS)]] | * [[ID selector (CSS)]] | ||
* [[Style sheet (web design)]] | * [[Style sheet (web design)]] |
Revision as of 10:24, 16 February 2016
In CSS, a class selector (or class style rule, or class style, etc.) is a selector which selects zero or more HTML elements based on the elements' class attribute.
It is used in combination with class attributes.
Example
Class selector:
.example { color: red; }
Note the period (.) which indicates that this is a class style rule.
Element affected by rule:
<div class="example">...</div> <p class="example">...</p>
The above example demonstrates that a class rule can affect two or more HTML elements, and that the elements can be different types.
- This is somewhat artificial, as a classroom example
- More commonly, a class rule affects HTML elements of the same type