It's all about
connecting the dots

CSS Selectors, Pseudoclasses, and Pseudoelements

Selector Type Example Note
Universal selector * { color:#555; } /
Type selectors b { color:red; } div,p select all <div> elements and all <p> elements.
Class selectors .classname { color:blue; } /
ID selectors #idname { background:cyan; } /
Descendant selectors span em { color:green } Select all <em> elements who have a parent element of <span>.
Child selectors div > em { background:lime; } Select all <em> elements who have a direct parent element of <div>
Adjacent sibling selectors i + b { color:gray; } Select the <b> element who is directly after the <i> element, and meanwhile both the <i> and <b> elements should be within a same parent element.
Attribute selectors a[href=’info.htm’] { color:red; } /
Pseudoclasses a:hover { font-weight:bold; } /
Pseudoelements p::first-letter { font-size:300% } /
赞(1) 打赏
版权声明:非商业用途转载请注明文章链接,商业用途转载请联系邮箱获取授权。
文章名称:《CSS Selectors, Pseudoclasses, and Pseudoelements》
文章链接:https://www.orzzone.com/css-selectors-pseudoclasses-and-pseudoelements.html
商业联系:yakima.public@gmail.com
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏