As Ryan said - that has nothing to do with a[href] matching <a href=""> which has an empty href attribute. a[href] doesn’t check for a non-empty href, it checks for whether the href exists or not (and matches even if it is empty as long sas it actually exists)
<a> tags with a href attribute behave differently from those without even with CSS since :link :visited :focus :hover and :active only apply where there is a href attribute.
I’d expect a:link and a[href] to target the same links except for possibly having a different .precedence. Neither would target <a name="topic">- of course without an id in that tag as well as the name it will not actually do anything in some more modern browsers given that the name attribute on that tag has been obsolete since 1997.
No. Ryan said that <a> will not “work” without href. I just noted that it can be used without href, as an anchor. But I didn’t say that it is supposed to be used that way.
Edit: seems like I misunderstood Ryan words. He meant “CSS selector will not work”, but I thought he means “tag will not work”. My bad, sorry.
Which browsers? It still works everywhere.
It is valid in HTML 4.0.1. Next version, HTML 5, was released only in 2014. So I don’t know how can it be obsolete since 1997 if it was a part of spefication that was actual until 2014.
“non-empty href attribute” is significant because that describes an href attribute that has a value, it does not mean that the href attribute must exist.
Ryan’s response
is exactly correct.
While you may have intended to say that the “href” attribute must exist, you actually said that it must contain a value… “a non-empty href attribute”… which is not true… all it has to do is exist.
If there is no href attribute, then the selector is not targeted, as you subsequently said.
My mistake, it is valid according to the standard but superseded by the id attribute which the standard appears to indicate is the preferred option - which is presumably why some browsers dropped support for name.
By the way, that’s not good HTML or CSS. There’s too much nesting in both languages. Normally you can do better. But I hope that clarifies the answer for you.
Html isn’t about ‘results’ or presentation its about structure.
In the first example it is clear from the mark up that the word school was deleted and the word college inserted.
In the second example the only certain thing is that the word school was deleted but we do not know with what it has been replaced (although we can obviously guess but that’s not the point). It’s usually used when published text has later been changed to show that the text and therefore the meaning may have changed also.
When you add the correct semantics to a document it allows tools/screen readers/ authors to extract more pertinent data from them.
I suppose you could use that markup to allow a user to display a pre-edit version, if you applied css to hide the <ins> and show the <del>, that way you would not need to have the two separate versions.
Hello, could you explain pseudo elements, I checked on w3schools but i still dont understand .Why we should use them instead of common elements. Purpose?
Pseudo elements is just a way to define different styles for different link states.
Each link can have many states: regular, hovered, clicked (active), focused.
This is how you make your link green in regular state (when it’s just displayed):
a {
color: green;
}
But what if you do want that link to become red when user puts mouse cursor over it?
Here is where pseudo-element comes to help:
a:hover { /* this rule applies when <a> is hovered by mouse */
color: red;
}