What is the css class selector?

CSS class selector class selector allows styling to be specified in a way that is independent of document elements. This selector can be used alone or in combination with other elements. Tip: These selectors can only be used if the document is marked up appropriately, so using them usually requires some forethought and planning. The most common way to apply styles regardless of specific design elements is to use class selectors. In CSS, the class selector is displayed with a dot, for example: .center {text-align: center} In the example above, all HTML elements with a center class are centered. In the HTML code below, both h1 and p elements have center class. This means that both will respect the rules in the “.center” selector. This heading will be center-aligned This paragraph will also be center-aligned. Note: The first character of the class name cannot use numbers! It doesn’t work in Mozilla or Firefox. Combined with other selectors Class selectors can be used in conjunction with other selectors, for example: element selectors. For example, you may want only paragraphs to appear as red text: p.center{color:red;} The selector will now match all p elements whose class attribute contains center, but not elements…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索