css icon indicating copy to clipboard operation
css copied to clipboard

Pseudo selectors before or after element properties?

Open SandmanPWNZ opened this issue 6 years ago • 12 comments

this:

.column {
    &:before {
    
    }
    border: 1px solid $special-text-color-blue;
  }

or this:

.column {
    border: 1px solid $special-text-color-blue;

    &:before {

    }
  }

SandmanPWNZ avatar Feb 01 '19 10:02 SandmanPWNZ

@nalabdou , have you read the title of issue? :) I'm asking which order is correct, do I add pseudo selectors for an element before element properties or after?

SandmanPWNZ avatar Feb 01 '19 10:02 SandmanPWNZ

I suppose as long as you choose something consistent, it’s fine?

conceptually it seems like I’d probably want “before”s to go at the top, and “after”s to go at the bottom.

ljharb avatar Feb 03 '19 00:02 ljharb

I always use mine after the element itself

GoodGuyGregory avatar Oct 16 '19 18:10 GoodGuyGregory

I think this is a question of personal patterns. I always write the Element Properties and than I go to the included elements. In this way I have a better overview about everything. But however you do it, you have to follow consistent, then it is better to read.

steve-klockow avatar Apr 10 '20 09:04 steve-klockow

it doesn't matter you can choose any of the two because writing pseudo selectors after or before element will make no difference.

jasbir91709 avatar Dec 15 '20 05:12 jasbir91709

I always use mine after the element itself

I use it like that... either for :focus & :blur etc... always at the bottom of the el { }

Hygor avatar Dec 15 '20 15:12 Hygor

test ok

JaneEye avatar Dec 29 '20 04:12 JaneEye

i test for two situation, both goes will

rudy0628 avatar Dec 09 '21 14:12 rudy0628

I usually pick the second one since it defines the pseudo-elements later after defining all the styling

ghost avatar Jan 19 '22 07:01 ghost

I think this is based on personal preference, as I normally write my pseudo selectors after

Sylar-codex avatar May 14 '22 06:05 Sylar-codex

from a maintainability perspective, the second code snippet is better because it places the border property first, then follows it with any pseudo-element selectors like :before. Makes the code easier to read in my opinion

Ay989 avatar Feb 24 '23 15:02 Ay989

you can put it anywhere you'd like, the code will not be affected by doing this

camoqq avatar Dec 27 '23 19:12 camoqq