Re: [csswg-drafts] [selectors] decide on :blank (#1967)

The `:blank` pseudo-class would significantly streamline dynamic form calculations, for example in educational contexts. It helps developers easily identify empty or non-empty input fields in CSS and JavaScript. For instance, in [this Stack Overflow post](https://stackoverflow.com/q/48111746), a teacher needs to calculate student averages based on test scores, but only for fields that have been filled (since students may skip optional tests).  

Currently, developers must rely on JavaScript event listeners to manually track input changes and count non-empty fields. This approach is cumbersome. With `:blank`, a **one-liner** like:  
```  
document.querySelectorAll("input:not(:blank)").length  
```  
could dynamically determine the divisor for averages, eliminating the need for hardcoded values and reducing complexity.  

This use case highlights the practical importance of `:blank` for forms requiring conditional logic based on user input. Its implementation would not only benefit educators but also improve form handling in surveys, assessments, and other interactive applications.  

**Proposed Action:** Prioritize the implementation and standardization of `:blank` to address real-world scenarios like this. Broader browser support would empower developers to build more robust and maintainable solutions with simple, elegant approaches.

-- 
GitHub Notification of comment by MortezaMirmojarabian
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1967#issuecomment-2656148260 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 13 February 2025 10:25:32 UTC