The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
Yea, that is a good idea to add line breaks on complex styles. I'm old school CSS and followed Eric Meyer's style back in the early 2000's, though I do break up complex styles to a certain point. I compare it to SQL. I hate it when I have to fix someone else's select statement and it has 50+ attributes all on separate lines and I have to scroll up and down to just get to the tables.
So that when you decide all your alert boxes will be flush left, or be in italics, or by pinned to the bottom, you're not changing classes on elements, you're changing the style definition of the alert-box class.
For layout I try and define broad types of layout (container, row, column etc) and use them in combination CSS classes that provide intent, not style. I'm not a fan of throwing HTML onto a pile and then using CSS to reorganise it on the screen, so if I'm changing layout I'm changing HTML, and so will change the element's CSS classes at the same time so everything reads sensibly.
I think what Chris writes here, and Marc alluded to in the original post, is an important point to be emphasized for beginners.
You want to describe the functionality. So, not that "this is a green message", but "this is a success message", so the style name gives some meaning to the use.
Often, this means that you have what seem like repeated (or very similar) styles, because the "success" message looks just like the "informational" message--but doing it on a functional level allows those things to more easily migrate away from each other in the future.
I still find it difficult to properly break the style from the structure of the page, so when restructuring happens, it often means style changes as well.
As to Marc's other question, I'm not so familiar with the cascading part.
At my last place, we just started using bootstrap for styling, it seemed like that was a really nice approach.
For perfect CSS in an ideal world (which seems to be what you want to talk about), I would say you should put every set of styles that occurs separately elswhere in the same project in a separate CSS class, while keeping the overall number of classes as little as possible. It can also be a good idea to draw additional separation lines between CSS classes "by subject" (page layout, object style, colors, fonts, ...) and put them not only into separate classes but into separate CSS files. This is an object-oriented CSS approach. By this, you for instance gain the possibility to have your design person maintain the colors.css for you, which means more control for her/him and less work for you.
But all this means a lot of effort, because as your project progresses, you sometimes have to split one CSS class into two or vice versa and then refactor all usages of these classes. But the more experienced you become with this approach, the less this will happen bc you will learn to think ahead to avoid the pain of refactoring. And that's when your initial effort will pay off, for yourself and for your company as well.
Cascading can be very useful in everyday practice for doing a rather loose specification in a more top-level element and be more precise in a child/descendant element. Or a second use case I can think of from my everday practice is to define a "base" style for a bunch of elements and still be able to "override" them and specify exceptions in particular cases.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
USB C, well just run on down to the shops and buy a Mac.
but seriously the department stores that sell PC's and iplods usually sell various adapter cables, seeing as the iplod has USB C they would probably have charging cables ... these days even some $1 shops have them.
I like it here. People are good, the city is nice and there are plenty of places for my son to have fun. We don't know anyone around so sometimes it gets boring. Still amazed by your fascination with calendars and plans. Got an invite in July for a barbecue in September.