简体   繁体   中英

<span> tag css style declaration inside <div> tag

I am having trouble doing the task below.

"Please change the text color in the span tag in the third div tag to red. For this purpose, please use the identifier attribute by assigning it to the aforementioned div tag and then create an appropriate selector using the mentioned identifier."

I tried to do it like this but unfortunately it doesn't work:

 div span#red { color: red; }
 <div class="golden-background third" id="red"> <---- id spank declaration inside div tag <h1>Nagłówek 1</h1> <p> To jest przykładowy <span>tekst...</span> <---- "tekst..." should be red </p> <p> Oto nasz odnośnik: <a href="http://www.pcz.pl" target="_blank">link</a> </p> </div>

div#red span {
    color: red;
}

You are not targeting the span item on your CSS. You are targeting any span elements which have the id #red

To solve this you have to add the id red to your span element

<span id="red">Your Text</span>

#red {
  color: red;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM