CSS :focus-within Selector Last Updated : 24 Jul, 2024 Comments Improve Suggest changes Like Article Like Report The :focus-within pseudo-class is a selects an element that consists of a focused element as a child. The CSS rules are applied when any child element gets focus. Example includes clicking a link, selecting an input, etc.Syntax::focus { /* CSS Properties */}Example: Below is the example which illustrates the use of :focus-within pseudo-class Selector. HTML <!DOCTYPE html> <html lang="en"> <head> <style> form { border: 2px solid red; padding: 15px; width: 30%; } form:focus-within { background: #ff8; color: black; } input { margin: 5px; } </style> </head> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <form> <label>Geek 1</label> <input type="text"> <br> <label>Geek 2</label> <input type="text"> </form> </body> </html> Output: Supported Browsers:Google Chrome 60+Edge 79+Firefox 52+Opera 47+Safari 10.1+ Comment More infoAdvertise with us Next Article CSS :focus-within Selector T thacker_shahid Follow Improve Article Tags : Web Technologies CSS CSS-Selectors Similar Reads CSS :focus Selector The :focus CSS pseudo-class Selector is used to target the focused element ie., it selects an element that is currently focused by the user. This selector works on user input elements, generally used in forms, and is triggered as soon as the user clicks on it or taps on an element, or selects any ke 2 min read CSS :target Selector The target selector is used to represent a unique element (the target element) with an id matching the URL's fragment. It can be used to style the current active target element. URLs with a # followed by an anchor name link to a certain element within a document. The element being linked to is the t 2 min read What is mouse down selector in CSS ? In this article, we are going to learn about the mouse-down selector in CSS. The mouse-down selector means the method to detect whether the primary mouse button is clicked or not. In CSS, the function of the mouse-down selector is done by the active pseudo-class. We can add this pseudo-class to the 2 min read What is Descendant Selector in CSS ? In this article, we will see the descendant selector, provided by CSS, along with understanding its implementation through examples. A CSS Selectors are used to select HTML elements based on their element name, id, attributes, etc, which facilitates to select more than one element simultaneously. De 3 min read CSS ::selection Selector The ::selection CSS pseudo-element allows you to style the part of a webpage that users highlight, such as when they drag the mouse over text. Itâs a simple way for developers to customize the appearance of selected text, improving the overall user experience. However, only a few CSS properties can 2 min read Like