Attribute Selector for Specific Content

I haven’t found an answer to my research regarding using Attribute Selectors to format text based upon a phrase. I know that this can be done with PHP/jQuery, but I’m wondering if it’s even possible to do so with CSS alone without applying a ‘class’ or ‘span’ to the specific phrase?

For example, for every word (‘pulley’) within a paragraph I would like to format it using CSS. Is there any way to do this without adding classes/spans?

The very premise of CSS is to SEPARATE content from style. So the answer is no, CSS cannot target “content”

Additionally, there is a SEMANTIC concern to your question. If you are styling some content fora REASON… you should use the PROPER TAG that indicates the reason. Example , if you are placing emphasis on the word “pulley” you NEED to use an EM tag. If you just are styling for purely aesthetic reasons then you would use a SPAN.

LAZY TIP, B and I tags also have no semantic meaning so if you feel you feel to lazy to type SPAN you can use I or B w/o affecting semantics ( just rember that the text will be bold or italics with CSS off)

hope that helps

The idea is to style a particular phrase throughout the whole site without having to use tags on every single page the phrase is being used. So I guess going with jQuery or PHP would have to do the trick.

With JavaScript it would be quite simple (although you would still be injecting the tags into the page).
Let me know if you need any help.

CSS is not meant for this use.

The idea is to style a particular phrase throughout the whole site without having to use tags on every single page the phrase is being used. So I guess going with jQuery or PHP would have to do the trick.

Am going to guess that this is because you are building the site off a CMS and do not want to input the tags at data entry, other wise ti really doesnt make much sense.

As Pullo said, .js (or jQuery) could accomplish this ( by searching the content and then wrapping the tags around it). So in essence you are still adding tags… just the hard way.

I would advice to use PHP , instead, to search/ replace phrase with tags around it during output. Plus that way your styling would remain intact if users have .js turned off, not to mention (again) that proper tag usage has SEO/semantic benefits.

The very premise of CSS is to SEPARATE content from style. So the answer is no, CSS cannot target “content”

You’re right but CSS can generate content and use HTML attributes so the lines are starting to blur.

I’d opt for JavaSscript for something like this.