Home  >  Article  >  Web Front-end  >  CSS designated selector (11)_html/css_WEB-ITnose

CSS designated selector (11)_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:46:001087browse

1. Specify the selector

Sometimes you want to control the object style of an element within a certain range. In this case, you can combine the element with the Class or Id selector. It is very useful to use

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>指定选择器</title><style type="text/css">span.red{    color:red;}div#top{    color:blue;    }</style></head><body><span class="red">这是个SPAN类名为CLASS</span><span>这是个SPAN</span><div id="top">这是个DIVID是TOP</div><div >这是个DIV</div></body></html>

to specify a selector object to define a certain element whose style is limited to the class or id attribute. Its control precision of the element is between the label selector and the id or class Between selectors, it is a very practical selector type

For example, how to control the text of news in the module below

<div><h2 class="news">新闻标题</h2><p class="news">新闻正文</p><span class="news">新闻说明</span><p>其它文件信息</p></div>

css

div p.news{    font-size:18px;    color:#FF00FF;    }

or

p.news{    font-size:18px;    color:#00FFFF;    }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn