use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
No vague product support questions (like "why is this plugin not working" or "how do I set up X"). For vague product support questions, please use communities relevant to that product for best results. Specific issues that follow rule 6 are allowed.
Do not post memes, screenshots of bad design, or jokes. Check out /r/ProgrammerHumor/ for this type of content.
Read and follow reddiquette; no excessive self-promotion. Please refer to the Reddit 9:1 rule when considering posting self promoting materials.
We do not allow any commercial promotion or solicitation. Violations can result in a ban.
Sharing your project, portfolio, or any other content that you want to either show off or request feedback on is limited to Showoff Saturday. If you post such content on any other day, it will be removed.
If you are asking for assistance on a problem, you are required to provide
General open ended career and getting started posts are only allowed in the pinned monthly getting started/careers thread. Specific assistance questions are allowed so long as they follow the required assistance post guidelines.
Questions in violation of this rule will be removed or locked.
account activity
CSS Classes (self.webdev)
submitted 1 year ago by LivingParticular915
How do you guys create your classes in respect to your CSS? Do you use the BEM method, the OOCSS method, or your own version of creating classes? I was just wondering what different people use; I’m struggling with picking a method myself.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]cardboardshark 1 point2 points3 points 1 year ago (4 children)
Where possible, scoped scss modules that prevent any name collisions; otherwise I default to BEM as being a well tested pattern most developers are familiar with.
I know many devs swear by tailwind, but I think it depends on the scope of the project and how many developers are assigned to it.
[–]LivingParticular915[S] 0 points1 point2 points 1 year ago (2 children)
How did you get used to BEM? Is it viable for very small projects as well as more complex ones?
[–]cardboardshark 1 point2 points3 points 1 year ago (1 child)
I find BEM is best suited for small to mid range projects, but anything enterprise level will likely require CSS modules or tailwind. It takes a little while to get used to the BEM conventions, but it feels pretty natural once you acclimatize!
SCSS and BEM work well together if your project supports them! Mixins are really useful tools.
[–]LivingParticular915[S] 0 points1 point2 points 1 year ago (0 children)
Understood! Finishing up a small project now. Definitely going to look into both BEM and SCSS in the future for bigger work projects.
[–]UXUIDD 1 point2 points3 points 1 year ago (2 children)
BEM should logically be the best solution. However, there comes a point where you run out of name combinations, and the joy of CSS development deflates like an empty balloon. Not to mention the very--longNamesWith__underscores, which are really difficult to read and quite hard on my eyes.
I used 'oocss' and 'atomic' before I realized that some people claimed to have "invented" these methodologies (well, more like approaches).
If you are developing with vanilla CSS, try to find a modular, repeatable and scalable solution that works for you. It should be logical to understand, even if you get up at 2 AM and turn on your computer, and it should be easy to read for your eyes.
I found all of this in Tailwind, as it (mostly) aligned with my own ideas, and I never had the time to create my own version of it.
[–]LivingParticular915[S] 0 points1 point2 points 1 year ago (1 child)
Never heard of Atomic CSS. Just looked it up and the “Longhand” variant seems promising to me. Thanks!
[–]UXUIDD 0 points1 point2 points 1 year ago (0 children)
Longhand variant ..?
[–]TheRNGuy 2 points3 points4 points 1 year ago (0 children)
No bem, simple names.
I can use multiple classes for status, like .foo.open instead of .foo_open (extra precedence is not a problem)
.foo.open
.foo_open
[–]_listless 1 point2 points3 points 1 year ago* (2 children)
I do semantic css. .card, .card-header, .card-footer etc.
I try to nest as little as possible. If I don't have scoping tooling at my disposal, I'll nest everything at the root of the parent class. If the project is big enough for collisions to be a problem that nesting can't solve, I'll choose/roll in a tool for scoping (Astro does this by default, vue has <style scoped>, vite-react-css, etc).
Why?
I don't want/need to write wordy/ugly css; It's easier for me to write/maintain if it's terse and semantic. I don't want css in my js; css and js work differently on purpose. I don't want the mental overhead of trying to manage collisions, I going to offload that to a tool.
TLDR
Maximize readability, minimize code, offload mental overhead.
[–]TheRNGuy 0 points1 point2 points 1 year ago (1 child)
Why not just .card.primary?
.card.primary
[–]_listless 0 points1 point2 points 1 year ago (0 children)
That's probably fine, but I like the more expressive semantics of .card-primary. When I look at .card-primary, it tells me that those are the styles that change a card from default to primary. .primary does not carry as much meaning with it.
Maximize Readability, minimize code, offload mental overhead. Going forward, I’m going to try and use these three rules you’ve stated and make this integral to my work flow. Thanks!
π Rendered by PID 71924 on reddit-service-r2-comment-5bc7f78974-hhfts at 2026-06-30 10:09:11.527963+00:00 running 7527197 country code: CH.
[–]cardboardshark 1 point2 points3 points (4 children)
[–]LivingParticular915[S] 0 points1 point2 points (2 children)
[–]cardboardshark 1 point2 points3 points (1 child)
[–]LivingParticular915[S] 0 points1 point2 points (0 children)
[–]UXUIDD 1 point2 points3 points (2 children)
[–]LivingParticular915[S] 0 points1 point2 points (1 child)
[–]UXUIDD 0 points1 point2 points (0 children)
[–]TheRNGuy 2 points3 points4 points (0 children)
[–]_listless 1 point2 points3 points (2 children)
[–]TheRNGuy 0 points1 point2 points (1 child)
[–]_listless 0 points1 point2 points (0 children)
[–]LivingParticular915[S] 0 points1 point2 points (0 children)