- This topic is empty.
-
AuthorPosts
-
August 1, 2013 at 9:06 am #145367
Frenchness
ParticipantHi all. I am new to this forum and have fun browsing the website, thanks!
I am even newer to wild card uses but love learning. I can’t find a solution for my ‘problem’ on the website and I am sure some smart people here do have an answer. Is it possible to create a class for a tags that do not have the href attribute? Like so:
a name=”link” rel=”friend”
How should I do this?
August 1, 2013 at 10:08 am #145372ElijahFowler
ParticipantThis is what you are looking for.
Markup:
This is a link This is a link
Style:
[name="link"] { color: red; } [rel="friend"] { color: green; }
August 1, 2013 at 8:12 pm #145421Martin Duran
ParticipantHi Folks,
That selector will work, but I’m not sure how well supported it is. My guess is that older versions of IE don’t support it.
Frenchness, to answer your question, yes you can add a class to an ‘a’ that doesn’t use a href=””. Style it as you please, it’ll work. And you can be sure that your styled will take place in even old IE browsers.
August 2, 2013 at 3:21 am #145470Frenchness
ParticipantThank you! And thanks to the good old F5 for refresh (thanks for the reminder, it’s a blast from the past) I can finally post a reaction :)
I am so new to this forum that I didn’t notice the buttons (they are probably too obvious, I am a details kind of person :D ) to post code. So I could not post the entire tags in the original message. It’s a learning curve :) However, here is the code example (some do not have the ‘rel’ attribute) but do have an id).
`<a name="link" rel="friend"></a>`
I realize I can style an ‘a’ tag without the href attribute but… I want to style all ‘a’ tags except the ones without the href attribute + I want to separately style the ‘a’ tags that do not have the href attribute.
So I tried this:
a :not([href]) {
background-color: #fff;
display: inline;
}But it doesn’t work :( It does though rescale images inside rollovers that do have the href attribute. I look forward to understanding this all.
August 2, 2013 at 5:00 am #145486dgriesel
Participantits
a:not(...)
and nota :not(...)
( no space between a and : )The first one selects an a-element without the href-attribute, the second one selects some element without the href-attribute inside an a-element.
August 2, 2013 at 5:21 am #145487Frenchness
ParticipantThank you.
I actually tried both yesterday but none worked. Just now though, after a fresh put on the server, it works! (Using the first option without the space).
Thanks a lot for the help. I am new to this kind of coding and it confuses me a bit. I hope to learn a lot from this forum and who knows, maybe one day I’ll be able to help others myself. I look forward to that!
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.