Pseudo Selector Solution?
I feel silly for asking this, but I'm currently trying to target something on a social site that allows custom code. I've been able to figure most things out.
But I'm currently struggling to find a possible solution.
On the site, in one section the header has words wrapped around a link.
If I use ::before, the whole thing changes. If I use :not() I can't exclude the href present.
Thought maybe I'm using it wrong with this current attempt.
The html essentially looks like such...
Is there a way to target just the sentence before the link or way to exclude the link? I want to change the before and essentially keep the link and the after if possible
Quick edit: The site does not allow for Java, so I'm limited to pure CSS.
13 Replies
what css properties do you want to change? It depends because some will cascade down (such as font, color etc)
*:has(>a)
will select the <h4>
but because that is the parent of <a>
some properties you change on the h4 will affect the link as well
otherwise, there always is javascriptHey @MarkBoots thanks for responding! I'm mainly looking for a way to replace the content.
That way if says "Latest Projects [view]" for example, I wanna change it to "New Post" [view].
So I need to target the words before the <a>, but :not(a) doesn't work, I've also tried :not([href]) and :not(href) assuming that works.
Also I should have clarified previously in the post. The site does not allow javascript. So everything I do is purely CSS based
Thanks!
replacing the text with css only is not possible
Noted. It's just on the site, what I've been doing is the following
So that's why I'm trying to figure how to target whats before <a>, that way I can alter and replace it like such. Which has worked on every part except the section I'm currently working on
as the text is not wrapped seperatly, i don't think there is a way. but will try and think about it
Yeah I had a feeling that might be an issue. So I assume I would likely just have to re enter the full thing with the link included. But if there is a way, that would be awesome!
Since you have to use JS to replace text. Do the whole thing in JS.
maybe i have something.
--edit: deleted the pen, see screenshot below
Hey Choo, thanks for the response, unfortunately on the site. I'm limited to pure CSS.
I'll make an edit to my post real quick. Because I did mention it once earlier!
WOW! That was quick! I'll give it a shot, one moment. Thanks, Mark!
So that almost works, I think I just need to trouble shoot it a little or figure how I can adjust it with my current code. Thanks again, Mark! I'll get back to you if I figure it out!
no problem, good luck
Hey Mark,
So I just played around with stuff again, and I think unfortunately that work. It looks like I'll just have to skip preserving the link all together. Which is still fine I guess.
I still appreciate you attempting to help find a solution. Still gave me some insight on how else to approach things!
for future reference (deleted the pen)
I greatly appreciate it! I'll save the screenshot for future reference!
Thanks again for everything!