CodeSolved

A comprehensive source of programming questions and exercises

Element selection within another element

Practice Easy 190/ Download 250 Views

CSS Code Write to select all spans that are directly inside DIV and change the color of their text to red

4 Answers

<!DOCTYPE html>
<html dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>span تگ </title>
    <style>
        div > span {
            color: red; }
    </style>
</head>
<body>
    <div><span>This text will be red.</span>
        <div>         
         </div><span>This text will also be red.</span>
        </div>
         <span>This text will not be red.</span>
</body>
</html>
div > span {
    color: red; # Change the color of the text to the red
}
Mma123 Download HTML & CSS
<!DOCTYPE html>
<html lang="en";>
<head>
<meta charset="UTF-8">
<meta name="viewport " content="width=device-width,intial-scale=1.0">
<title> box</title>
<style>
div>span{
    background-color: red;
}
div{
    background-color: aqua;
}
</style> 
</head>
<body>
<div >
<span>ghjkl</span>
</div>
<div>
    cfghjkl</div>
</body>
</html>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close