Is there a CSS selector for text nodes?

Rudie picture Rudie · Apr 16, 2011 · Viewed 144.3k times · Source

What I would like to do (not in IE obviously) is:

p:not(.list):last-child + :text {
  margin-bottom: 10px;
}

Which would give a text node a margin. (Is that even possible?) How would I get the text node with CSS?

Answer

Jacob picture Jacob · Apr 16, 2011

Text nodes cannot have margins or any other style applied to them, so anything you need style applied to must be in an element. If you want some of the text inside of your element to be styled differently, wrap it in a span or div, for example.