css - how to select last element in the page? -


is there way select last appear of specific element css?

this example: demo

i tried last-child not want. used class:

html:

<ul>     <li><span>test</span></li>     <li>         <span>test</span>         <span>test</span>     </li> </ul> <div>     <span>test</span>     <span>test</span> </div> <p>     <span>test</span>     <span>red</span> </p> 

css:

span:last-child{     color:red;     font-weight:bold; } 

i want last span "red" content red. how can css ?

update: there solution last-of-type elements same parents. different parents ?

try this: (you should aware of parent wrapper element)

body > *:last-child > span:last-child{     color: red; } 

working fiddle


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -