Is following CSS syntax valid?body { color: #FF0000;}div.filters p.title h2 span.text.big { font-size: 20px;}
Question
Is following CSS syntax valid?
body {
color: #FF0000;
}
div.filters p.title h2 span.text.big {
font-size: 20px;
}
Solution
The CSS syntax you provided is partially correct. The first part is valid:
body {
color: #FF0000;
}
This will set the text color of the entire body to red.
However, the second part is not valid:
div.filters p.title h2 span.text.big {
font-size: 20px;
}
In CSS, you cannot nest selectors in this way. Each selector should be separated by a space, which signifies any descendant of the previous selector. If you want to select a span
with both classes text
and big
that is a descendant of an h2
tag, which is a descendant of a p
tag with class title
, which is a descendant of a div
with class filters
, you should write it like this:
div.filters p.title h2 span.text.big {
font-size: 20px;
}
This will select the correct elements and apply a font size of 20px.
Similar Questions
Is following CSS syntax valid?body { color: #FF0000;}* { font-size: 14px;}
Is following CSS syntax valid?body { color: #FF0000;}h3,div.full_textdiv.small_text h4div.filters p.title { font-size: 20px;}
Question 7In the following CSS code, what is the color: part known as?123h1 { color: purple;} 1 pointCSS PropertyCSS RuleCSS SelectorCSS Attribute
How could this code be re-written but guarantee the same appearance in the browser?body h1 { color: #BB44FF;}
Which of the following is NOT a valid CSS property?*2 pointsfont-sizebackground-colortext-colormargin-top
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.