Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJames N
17,864 Pointswhen I change a:focus to :focus, my entire page turns orange!!!
when I change a:focus to :focus, my entire page turns orange!!!
5 Answers
Merritt Lawrenson
13,477 Points':focus' is the psuedo-selector that selects what's currently in focus. This usually means something you clicked on, like a link or some text. The pseudo-selector has to attach to an element, in this case the 'a' element. Your browser is trying to get around the error and decided that since you have the page selected, you must want the whole thing orange.
Muhammad Ateeq
Courses Plus Student 729 Points:focus is an pseudo class you need to attach it with some kind of element i.e(a, button). Your whole page turn orange because you had not specified the element you want to target. So, the browser look for the element and when he not find one he will simply apply those styles to your root element which is html. That's why your whole page turn orange. I hope this will help :)
Brian Douglas
822 PointsCould you post the code you are using.
:focus is a pseudo selector so will need to be attributed to some element in order for it to take effect.
Geoffrey Emerson
18,726 PointsIn the video, Guil specifically says that removing the "a" allows the ":focus" to apply to any element on the page that becomes active.
:focus {
color: white;
background-color: orange;
}
James, this code appears to be a problem in the Internet Explorer web browser. Is that what you are using?
I find that Treehouse videos and Workspace works best in Chrome, but Firefox seems to be adequate as well.
If you are using Internet Explorer, I recommend that you download a different web browser, and set the new browser as your default.
Isaiah Wojciechowski
3,163 Pointsi am having a similar problem except mine changes the background to orange (as it should) but not changing the text color to white
:focus {
color: white;
background-color: orange;
}
I've also tried using *:focus as the selector but the result is the same.
PS. I am using Chrome
Mark VonGyer
21,239 PointsIsaiah do you have any additional CSS that may be overriding that block?
Isaiah Wojciechowski
3,163 PointsMark, I don't see any and like I said if i change it to a:focus it works as expected
Mark VonGyer
21,239 PointsI suggest using *:focus instead of just :focus