Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select a text node with CSS

Tags:

People also ask

How do you select text in CSS?

The ::selection selector matches the portion of an element that is selected by a user. Only a few CSS properties can be applied to the ::selection selector: color, background, cursor, and outline.

Can you target text in CSS?

You cannot target text nodes with CSS.

How do I select a specific element in CSS?

The CSS id Selector The id of an element is unique within a page, so the id selector is used to select one unique element! To select an element with a specific id, write a hash (#) character, followed by the id of the element.

How do you target all text in CSS?

The * selector selects all elements. The * selector can also select all elements inside another element (See "More Examples").


I have the following HTML markup:

<h1> 
     <div class="sponsor"> 
          <span>Hello</span>  
     </div> 
     World 
</h1>

When I use the CSS selector h1 I get Hello World.

I can't unfortunately change the markup and I have to use only CSS selectors because I work with the system that aggregates RSS feeds.

Is there any CSS selector which I can take only the text node? Specifically the World in this example?