-
Notifications
You must be signed in to change notification settings - Fork 756
Description
Disclaimer
I imagined this would have been proposed three gazillion times by now.
Though I haven't found anything meaningful on the internet.
Therefore here we go.
Proposal
I propose a language feature to allow authors to define an arbitrary number of pseudo-elements similar to ::before and ::after.
Benefits
- Generally increased design possibilities due to having more elements to work with
- Possible reduction to DOM pollution (i.e non-semantic elements added for styling purposes)
- Possible reduction of DOM script complexity due to fewer elements having to be created by authors via javascript
I'm surely missing some good benefits here.
Problems
I am not really sure. Certainly, you people have great experience in spotting CSS proposal loopholes. Thank you!
Syntax
Here goes the first syntax that comes to mind.
p::leading(1) {
/* First pseudo-element */
}
p::leading(2) {
/* Second pseudo-element */
}
/* ... So on */
p::trailing(1) {
/* First pseudo-element after last child */
}
p::trailing(2) {
/* Second pseudo element after last child */
}
/* ... So on */Alternative Syntax
Maybe we can use names and define order in the properties.
p::pseudo(foo){
pseudo-order: 1; /* first pseudo element afrer children */
}
p::pseudo(bar){
pseudo-order: -4 /* before children and before -3, -2 and -1 */ ;
}Maybe we can just ignore ordering altogether and focus on using existing z-index and order behavior where applicable.
References
I'm gonna quote this old article because yes.
PS.: It's the first time I post in here, so please, let me know (and sorry) if I'm doing anything wrong.