---
title: "Discussion on \"Why CSS :focus-within is amazing\" | Hashnode"
description: "Discussion on \"Why CSS :focus-within is amazing\". This is not a :focus selector, which will highlight when you focus on an element.\nBut a selector to fire when something within is focussed.\nIn our case, we'll be focusing on forms (I see what you did there 😏)\nThe end result will look like this:\n\nHTM..."
url: "https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Why CSS :focus-within is amazing](https://h.daily-dev-tips.com/why-css-focus-within-is-amazing?utm_source=hashnode&utm_medium=feed)

This is not a :focus selector, which will highlight when you focus on an element. But a selector to fire when something within is focussed. In our case, we'll be focusing on forms (I see what you did there 😏) The end result will look like this: HTM...

Nov 10, 2020 · 2 min read · h.daily-dev-tips.com  
Read the article

-   [#css](https://hashnode.com/tag/css)
-   [#css3](https://hashnode.com/tag/css3)
-   [#programming](https://hashnode.com/tag/programming)
-   [#2articles1week](https://hashnode.com/tag/2articles1week)
-   [#html](https://hashnode.com/tag/html)

## Written by

[Chris Bongers](https://hashnode.com/@dailydevtips)

@dailydevtips · Cape Town, SA

  
[View profile](https://hashnode.com/@dailydevtips)

Looking to get into development? As a full-stack developer I guide you on this journey and give you bite sized tips every single day 👊

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.

## Responses 5

Markdown supported · ⌘↵ to post

[Adam](https://hashnode.com/@kanapka94)

[Nov 17, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5fb42c8fa73df361ab711844)

I really appreciate your discovery! Thanks for sharing your knowledge :) I will definitely use it :)

[Chris Bongers](https://hashnode.com/@dailydevtips)

[Nov 18, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5fb42c8fa73df361ab711844#reply-5fb4a997b589f1618af9e295)

Thanks for this comment Adam, Will keep sharing these cool finds with you guys

[Stefan Natter](https://hashnode.com/@natterstefan)

[Nov 10, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5faac5b3d6009557c49f59e5)

Thanks for making me aware of this. It comes with no surprise to me that IE does not support this. I'll be forever happy when the browser is not used anymore. :D

[Chris Bongers](https://hashnode.com/@dailydevtips)

[Nov 11, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5faac5b3d6009557c49f59e5#reply-5fab71ccd6009557c49f6105)

100% Let's hope this browser just disappears for good, not even mentioned in canIuse etc...

[Stefan Natter](https://hashnode.com/@natterstefan)

[Nov 11, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5faac5b3d6009557c49f59e5#reply-5fab7834d6009557c49f61f8)

Yes, imaging looking at all those tables and there is no red column anymore!

[Tapas Adhikary](https://hashnode.com/@atapas)

[Nov 10, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5faabb67621a1f57a3d0670c)

Good, I learned something new with this... Thanks!

[Chris Bongers](https://hashnode.com/@dailydevtips)

[Nov 11, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5faabb67621a1f57a3d0670c#reply-5fab71acd6009557c49f60e6)

Awesome! Can't believe I got to teach you something new 😋

[Jesper Hasselquist](https://hashnode.com/@Joxtacy)

[Nov 10, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5faa92ac1ef56b5545aafb4d)

Really nice article on the `:focus-within` pseudo-class! Really good use of it! 🥳 I would just like to make a few clarifications, if you don't mind.

`::before` and `::after` are [pseudo-elements](https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements) and not pseudo-selectors. And technically `:focus-within` is referred to as a [pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes). Pseudo-elements should generally be used with double `::` to tell them apart from pseudo-classes which should be referred to with a single `:`. They are all used together in [CSS selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors).

[Chris Bongers](https://hashnode.com/@dailydevtips)

[Nov 10, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5faa92ac1ef56b5545aafb4d#reply-5faaaecec9b29b563d0c1098)

Hey Jasper, nice addition you are absolutely right on that actually!

[Emily Boston](https://hashnode.com/@emilyboston)

[Nov 10, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5faa1b5604e4a94a40f0d741)

I have never used `:focus-within`. It's really interesting. Thank you, Chris, for writing this post.

[Chris Bongers](https://hashnode.com/@dailydevtips)

[Nov 10, 2020](https://hashnode.com/posts/why-css-focus-within-is-amazing/5faa199c04e4a94a40f0d653/comment/5faa1b5604e4a94a40f0d741#reply-5faa1cd504e4a94a40f0d7cd)

Thanks for your comment Emily, It's also new for me, but looks pretty cool.
