Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it worth separating "style" from "layout" in CSS
    primarykey
    data
    text
    <p>One of my biggest trouble with CSS has always been how tricky it is to position stuff appropriately. </p> <p>Now matter how hard I try to understand things, I always need a couple of tries before I can guess which must be floatted in which direction related to what. </p> <p>Now, my trouble is, I usually at some point have code like this : </p> <pre><code>&lt;div class="someContainerThatWillWorkAsALine"&gt; &lt;div class="someOtherContainerThatWillWorkAsAcolumn"&gt; &lt;div class="StuffInAcolumn"&gt; ... &lt;/div&gt; </code></pre> <p>The only purpose of classes like this is to say :</p> <ul> <li>"child, please go from left to right"</li> <li>"except you guys, please go from top to bottom"</li> <li>"you, stop disturbing your brother and go 5px to the left, you're grounded"</li> <li>"johnny, you're the last of your breed, please clear all those floating nonsense" </li> </ul> <p>I sometimes come to wonder if I'm writing software, or trying to find the right way to turn the antenna to receive old-style analog TV. </p> <blockquote> <p>"Ok, just a little more to the right, please... No, not quite there yet. Perfect now, don't move !"</p> </blockquote> <p>Besides, those classes have no real semantic, so it's <em>very</em> hard to give them a meaningful name. This makes CSS pretty hard to read, and, even worse, pretty hard to <em>write</em> because I get a panic attack every time I have to choose a name for "yet-another-class-that-simply-tells-a-block-to-act-as-a-line". Because as every class name is global to your web2.0-y-one-page-site, you don't want to collide with used names.</p> <p>So how do you tackle this kind of problems ? Do you : </p> <ul> <li>leave the "positioning" (layout?) css code inline with your html, and restrict CSS to actual styling (as in "this should be blue, this should be written in bold, etc...") ? </li> <li>simply have one "act-as-a-line" and "act-as-a-column" class (meaning your html code contains classes that only deals with layout), which kinda defeats the "keep layout out of my html" spirit ? And give a more meaningful class for other cases ?</li> <li>use a convention for the names ?</li> </ul> <p>Any ideas welcome.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload