Linking and Action Selectors
In the last lecture we saw the core CSS selectors (id, class and element) as we wrapped up the chapter with the modern new joker selector (the universal selector). In this lecture we turn out attention to action and actionable related pseudo classes. By the end of this lecture, you will know how to control the colors of actions and links in CSS and will be up-to-date with the changes that have taken place with them.
properties: link pseudo class(CSS1), user action pseudo classes(CSS2), :link, :visited, :active, :hover, :focus
Video Transcript
00:00We're still deep into the world of CSS Selectors. In the last lecture
00:04We met the Joker selector or the Universal selector. In this lecture
00:09we're going to take a deeper look into Link Selectors and we grouped together a few selectors some from CSS 1 and
00:16CSS 2 but with it by the end of this lecture
00:18You will know all the CSS selectors that relate to links. So let's jump right into them and let's meet them
00:25Inside of our selectors chapter
00:27You're gonna find a link right in one of the paragraphs and below you'll find also a few text boxes
00:33The point of this lecture is really to talk about the link pseudo classes, which have been available since CSS 1
00:40I'm just gonna go ahead here and put here a title so you could refer back to it whenever you want to and the next ones
00:45Are gonna be user action pseudo classes now the idea behind the word pseudo is basically because there is no class there
00:52It's like a fake class. It's like a kind of class, right?
00:55So instead of having a pseudo class basically enables me to create a
01:01Rule for links so for example
01:03If I wanted to go to all a links and I want to just set them for their link to be in a different color
01:08Let me just go ahead there and I'm gonna set a different color to our a link and I'm gonna set its color
01:12How about we set the color to be white?
01:16All right
01:16So we just set an a link it is color is gonna be white if the user never visited in that specific item
01:22Then it will be white another element of the links is enables us to create a visited attribute visited
01:29and in that case, I'm gonna set my color to be red and
01:35I'll go ahead and save it and if I go back into my application and click on refresh
01:39We'll see that now our link is white if I click into it
01:43The color as you notice changed to be red if I come back here, you'll see that my color is red now
01:49This doesn't always work perfectly in modern browsers
01:53especially Firefox even though we're running currently on Firefox and that is because the
01:58specification has changed and part of that specification comes to security because there are ways for users to basically grab the color that's on
02:07the screen of
02:08Elements on the page which means that they might be able to know your traveling path and that could be very dangerous because then
02:16Developers will be able to know if you visited a certain page or not even if you disabled tracking
02:22So one of the stuff is that some some versions of Firefox just don't have it at all
02:27It is still part of the specification
02:29But in that specification there is a definition a newer definition that marks that security risk and saying
02:36Make sure that developers won't be able to read that information
02:39Some browsers just decided just we're just not gonna enable you to control the color of the visited links
02:46That's gonna stay in the hands of the browser
02:48So if you in your specific browser you see right now that the link does not work that you don't see the visit
02:53that's because
02:55Part of specification enables the browser to decide if they're gonna actually adhere to that visited or not
03:02So I want to talk to talk further oto about another thing since CSS to and onwards
03:07We don't really have to define what we're actually specifying so I could just say
03:11Visited and that by default our browser will know that we're referring to a link and we're referring to a
03:18Visited link and that is because in the new world there is those stars
03:22So by default when you don't put anything we basically say we're basically saying everything in that case
03:27So if I go ahead and click on save you'll see that in this scenario
03:31Our link will still be read even though we didn't define it as every a tag
03:35So I'm just gonna leave your one with the a tag
03:37So you'll have a reference to the old way of doing it in CSS one and without anything
03:42Which is the way you could do it in CSS to and onwards because you just it's just redundant
03:46We're basically saying any link will have that
03:49Specification. Alright, so let's move on to the CSS to specific although there's some that has been available also in CSS one
03:56And I want to talk about the active
03:58So I'm gonna start off by setting a specific I'm gonna go ahead and say hey
04:02I want to o to link to our a when it's active now
04:06The difference here is that even though I'm talking to a link. This is not a link pseudo code code
04:10It's a user action one because active means is that it's currently being engaged and in this case
04:15Let's say I want to set the color
04:17To be black. So as it's getting set as it's getting click
04:21I want the the the action itself to show me that click
04:26So you can see that as I'm clicking on it the color is changed. Okay, so let's continue
04:31So those though that was the active there's two more that I want to cover in this lecture and for that
04:36I'm gonna move on to our inputs and I want to say to all my inputs every input that exists
04:42I want to set a hover something hovering over it. So whenever the user is hovered over I want to do something
04:48for example when the user hovers on how about we set that the color in
04:53While the user is hovered, but the item is not focused
04:56We're gonna set a color to the let's do it to the border color
05:00Let's set a border color and to the border. Let's say I'm gonna set a border color of red
05:05I'm gonna go ahead and just continue immediately so we don't waste too much time
05:09toes are talking about the focus and the difference between focus and
05:14Hover so focus is when the item itself is actually selected already. There is no action already
05:20It's already in there in this case. Let's set a border color as well
05:23And I'm gonna set a border color. Let's me and make it black just for the sake of simplicity
05:30so if I go ahead here and click on refresh and
05:33I'll scroll down to those text boxes notice that now when I roll over a text box
05:38I have a red shadow around it a red a red border around the item and once I click into it
05:45the border turns black and
05:48There we go, that's it
05:50that is all of the actions and all of the all of the actions and all of the link related actions that we could do in CSS
05:581 2 and
06:003 for that matter
06:01So we'll see you in the next lecture where we continue exploring different selector rules that we could do in CSS in the world of CSS 3
