There are three basic selectors in css, namely: 1. Tag selector, also known as type selector, matches all tags of the specified tag element name; 2. Class selector, matches the specified class All elements are styled; 3. The id selector can specify a specific style for HTML elements marked with a specific id.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
Basic selector in css
(1) Tag selector
p { background-color:red; color:blue; }
(2) class selector
There is an attribute class in each HTML tag
<div class="haha">愿有岁月可回首,且以深情共白头!</div> .haha { background-color:blue; }
(3)id selector
Every Each HTML tag has an attribute id
<div id="hehe">愿有岁月可回首,且以深情共白头!</div> #hehe { background-color:blue; }
Priority of basic selector
style > id selector> class selector> tag selector
Recommended tutorial: CSS video tutorial
The above is the detailed content of What are the basic selectors of css?. For more information, please follow other related articles on the PHP Chinese website!