Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - What is the meaning of this selector

adfafdadfadsf
div.alert.error {
background:url("v3.png") no-repeat scroll 7px -643px #FFEEEE;
}

Does the selector "div.alert.error" mean the following?

select DIVs that contain both class alert and error.

Is there a different between

CaseI:   div.alert.error
CaseII:  div.alert .error
CaseIII: div .alert .error

Thank you

like image 755
q0987 Avatar asked Aug 25 '10 17:08

q0987


People also ask

What are the 3 selectors in CSS?

Simple selectors (select elements based on name, id, class) Combinator selectors (select elements based on a specific relationship between them) Pseudo-class selectors (select elements based on a certain state)

What * means in CSS?

The Universal Selector is the * in CSS. Literally the asterisk character. It is essentially a type selector that matches any type. Type meaning an HTML tag like <div> , <body> , <button> , or literally any of the others. A common use is in the universal reset, like this: * { margin: 0; padding: 0; }

What is an example of a selector in CSS?

A type selector selects all HTML elements that have a given node name. For example, “a” would select all <a> elements and apply the CSS property values to them. “Input” would select all <input> elements, “span” all <span> elements and so on.


1 Answers

CaseI:   div.alert.error

A div with classes alert AND error. <div class="alert error">

CaseII:  div.alert .error

An element with class error that is a descendant of a div with class alert.

CaseIII: div .alert .error

An element with class error that is a descendant of an element with class alert, that in turn is a descendant of any div.

like image 147
Ken Redler Avatar answered Oct 05 '22 01:10

Ken Redler