Knowee
Questions
Features
Study Tools

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;}

🧐 Not the exact question you are looking for?Go ask a question

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 or a greater than sign (>). The correct syntax would look something like this:

div.filters p.title > h2 > span.text.big {    
    font-size: 20px;
}

This will select a span with the classes text and big that is a direct child of an h2 element, which is a direct child of a p element with the class title, which is a direct child of a div with the class filters.

If you want to select an element that is a descendant (not necessarily a direct child), you can use a space:

div.filters p.title h2 span.text.big {    
    font-size: 20px;
}

This will select a span with the classes text and big that is a descendant of an h2 element, which is a descendant of a p element with the class title, which is a descendant of a div with the class filters.

This problem has been solved

Similar Questions

Is following CSS syntax valid?body { color: #FF0000;}* { font-size: 14px;}

Is following CSS syntax valid?body { color: #FF0000;}* { font-size: 14px; text-align: center; margin: 30px 12px 4px;}

Is following CSS syntax valid?body { color: #FF0000;}h1.title { font-size: 16px;}

Is following CSS syntax valid?body { color: #FF0000;}h3,div.full_text,div.small_text h4,div.filters p.title { font-size: 20px;}

Is the following HTML markup valid?<html> <head> </head> <body> </body></html>

1/4

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.