21
points
Questions
2
Answers
1
Q: Which selector has high priority in CSS?
CSS selectors are used to “find” (or select) HTML elements based on their element name, id, class, attribute, and more.css selectors are 1.ID
2.class
1.The id selector uses the id attribute of an HTML element to select a specific element.ID’s are unique
*Each element can have only one ID
*Each page can have only one element with that ID2.Class selectors are used to apply style to multiple HTML identified with the same class.
Classes are NOT unique
*You can use the same class on multiple elements.
*You can use multiple classes on the same element.lets see the which selector is high priority
Priority 1 : ID ID
Priority 2 : ID Class
Priority 3 : ID Element
Priority 4 : ID
Priority 4 : Class class
Priority 6 : Class Element
Priority 7 : Class
Priority 8 : Element<!DOC-TYPE html>
<html>
<head>
<title>selectors high priority</title>
<style>#abc #def {
color:red;
}
#abc .a {
color:blue;
}#abc a {
color:black;
}
#abc {
color:red;
}
.abc.def{
color:black;
}
.abc a {
color:white;
}
.abc {
color:green;
}
p {
color:pink;
}</style>
</head><body>
<div id=”abc” <a href=”http://www.w3schools.com”>Visit W3Schools.com!</a></p>
<p>w3schools</p></div>
</body>
</html>- 1878 views
- 1 answers
- 0 votes