When I begin writing text in the textarea, I want the outer div, with a class box, to have it\'s border turned solid instead of dashed, but somehow the :focus doesn\'t apply
DIV elements can get focus if set the tabindex attribute. Here is the working example.
#focus-example > .extra {
display: none;
}
#focus-example:focus > .extra {
display: block;
}
Focus me!
Hooray!
For more information about focus and blur, you can check out this article.
Update:
And here is another example using focus to create a menu.
#toggleMenu:focus {
outline: none;
}
button:focus + .menu {
display: block;
}
.menu {
display: none;
}
.menu:focus {
display: none;
}