Coding Horror: What's Wrong With CSS
codinghorror.com
codinghorror.com
I personally like the ideas behind languages the Lisp community is developing via Weblocks and UCW (on top of yaclml or cl-who) -- and the similar possibilities provided by perl's Catalyst::View::TD -- where you approach page design from the perspective of widgets combined on a page.
Here is what is forced on us with this flat data approach: The server bears the weight of producing the flat data, and the network has the burden of carrying that large flat data from the server to the client. The client must render all that flat data. If the data had means of abstraction, the server would not need as many intermediate layers to convert it, the network would have less to transfer, and the client browser would be able to take advantage of optimizations for abstractions and parse less data.
Has anyone made any real headway on getting a replacement for HTML browsing? a movement away from "pages" and more towards "gateways" or "portals" to the graphical net?
We can do better with/than HTML. We can do better with/than CSS.
Good luck implementing Xanadu.
We both know CSS. But we use them entirely differently.
On a site with 500+ pages, by the time you've implemented all of your !blue to !green, or !light_orange to !dark_orange throughout your stylesheets, management will be considering another redesign.
I find that for simpler sites, naming colors after their closest tone works well, but when I have a dozen shades of the same color, I start to run out of names very quickly (e.g. it's not unusual for me for a single page to have different background boxes, zebra striped tables, subheaders, selected/hover states and an array of other details on top of the overall layout)
Your variable names represent a value, not a color. You should ask yourself what the function of that value is before naming the variable.
But that's just me. CSS is not something you can let slide. Adding templates, widgets, and pages on a mass scale (20+ templates, 30+ widgets, 500+ pages), your CSS deficiencies will show quickly.
Thanks for being patient with me while I explore alternative solutions.
Anybody have a method they feel good about and would like to share?
Same as in normal programming, really.
I guess its hard for me to put names on 3-6 colors that are used in various places on the site. This is probably just because I don't have a good idea going in where I'll be using these colors and I end up using them in places that don't apply to the name given.
For instance, I'll name a variable "background_color" and then I'll want to use it somewhere unrelated.
Semantic markup and CSS is something to strive for, but don't kill yourself trying to get to 100%
!theme_primary !theme_secondary !theme_accent
!theme_primary_dim !theme_secondary_dim !theme_accent_dim
!theme_primary_bright !theme_secondary_bright !theme_accent_bright
s/theme/palette/
.primary-1 { background-color: #FFDDC2 }
.primary-2 { background-color: #E5C9B4 }
.primary-3 { background-color: #DAAA84 }
.primary-4 { background-color: #FFEBDB }
.primary-5 { background-color: #FFF6EE }
.secondary-a-1 { background-color: #FFE6C2 }
.secondary-a-2 { background-color: #E5D1B4 }
.secondary-a-3 { background-color: #DAB784 }
.secondary-a-4 { background-color: #FFF0DB }
.secondary-a-5 { background-color: #FFF8EE }
.secondary-b-1 { background-color: #FFCFC2 }
.secondary-b-2 { background-color: #E5BEB4 }
.secondary-b-3 { background-color: #DA9684 }
.secondary-b-4 { background-color: #FFE2DB }
.secondary-b-5 { background-color: #FFF2EE }
.complement-1 { background-color: #C2FFFD }
.complement-2 { background-color: #B4E5E3 }
.complement-3 { background-color: #84DAD7 }
.complement-4 { background-color: #DBFFFE }
.complement-5 { background-color: #EEFFFE } // >> HEADER/FOOTER
// background color for header/footer
!nav_background = #5C504F
// border of header/footer
!nav_border = #5C504F + #2B2830
// text in header/footer
!nav_text = #F0F8FE
// >> BACKGROUND BEHIND CONTENT
// background between content and nav elements
!site_background = #2B2830
// border between background and content
!site_border = #ABAB8E
// >> CONTENT
// background for content
!content_background = #F0F0D8
// table odd row
!content_lighter_background = #F0F0CA
// text color
!content_text = #000
// regular links in content
!content_links = #2B2830
// control links (flag, edit, delete, etc.)
!content_edit_links = #8B8870
// secondary nav border, section seperator, table header seperator
!content_seperator = #D9D7A3
Screenshot: http://epochwolf.com/singleforestcom-screenshot # Ruby version
$ time lessc -v
lessc 1.2.21
real 0m1.681s
user 0m1.492s
sys 0m0.176s
# Node.js version
$ time lss -v
lessc 2.0.0 (LESS Compiler)
real 0m0.104s
user 0m0.088s
sys 0m0.016s
Though it should be noted that Rubygems has introduced a bit overhead in
the Ruby version.Also, a 1.5-second speedup is not terribly compelling for something done rather infrequently (and if you're not caching or pre-processing to static files, you're doing it wrong).
At the very least I could see myself using it in the browser for development.
.uno {
color: green;
font-size: 18px;
text-align: center;
}
.dos {
color: green;
font-size: 18px;
}
can become .uno, .dos {
color: green;
font-size: 18px;
}
.uno {
text-align: center;
}
also, as others have pointed out, nesting is kind of there in the form of a hierarchy. child elements will get parent styles for most properties. .uno {
@extend .dos;
text-align: center;
}
.dos {
color: green;
font-size: 18px;
}One issue I'm dealing with on this setup is that these skin files are site dependent and outside of the base code repo. They're in their own repo, but the issue is every site has its own files, so to add a new variable to the skin file requires adding it in 5-10 places, and that number is just going to get bigger. I'm curious if you guys have any suggestions.
"why CSS needs no variables" http://meiert.com/en/blog/20090401/why-css-needs-no-variable...
One example is the ability to distinguish in code between !warningColor and !saleColor even if they happen to be the same value of red at a given point in time.
Another is increased readability, since scanning a stylesheet and quickly seeing that #f54e4f and #f5e4f4 are very different colors is difficult.
Additionally in Jeff's case constants would allow for one complex stylesheet which maps selectors to constants to be shared across all skins, and then each of the 10 skins can be simply definitions of constants.
The big problem with CSS without variables is the time and effort it takes to make changes. If you only have to change the declarations once, at the top of the file, well it doesn't get much easier.
Unfortunately the SASS preprocessor doesn't do that... yet. The main draw of SASS is the ease of development and maintainability, not reducing the byte size of your CSS files. Personally, I don't want to spend the time manually hunting through CSS to combine selectors in order to save a few bytes.
To give you a more practical example, instead of a color like #efac68, imagine the variable held the value 1em or 10px. If you wanted to increase the width of the gutters between columns, it's easier to change $gutter than to try a find and replace of 10px in your CSS, while trying to only change the values you want.
I guess it's a bit like his business partner Joel quitting blogging, hasn't got a great deal left to say.
Sometimes connecting the dots is all a blog post needs to do.