/    Sign up×
Community /Pin to ProfileBookmark

It’s time to ditch CSS… Thoughts?

CSS, in my opinion, has always been an awful system for laying out pages… almost absurdly so. There are so many aspects of the specification that simply do not make any sense (like how vertical padding and margin are relative to the width of the parent… what?), to the point that every time I try and use CSS I begin to question the sobriety of whoever came up with it. Almost anything you try and accomplish using CSS requires some sort of workaround involving nested divs, and ultimately you have to resort to javascript for certain features. Add to this the fact that it is implemented inconsistently across browsers, and that each browser requires some prefix for css properties (which means almost any of the new CSS3 features have to be written 3-4 times) and the result is a giant mess.

So I decided to try a little experiment. Since I end up using javascript anyway to accomplish most layouts, I thought I might be better off ditching CSS altogether, at least for page structuring. I wrote a javascript library which parses layouts specified in XML files, and applies them to an HTML document using absolutely positioned and sized, non-nested divs. So the idea is that each page has an HTML file containing all content, an XML file specifying how that content should be arranged on the page, and a CSS style sheet used only for superficial styling.

here are a few examples (tested in the latest version of all the major browsers):
[URL=”http://sandbox.pursuebeauty.net/yule/”]Example 1[/URL]
[URL=”http://sandbox.pursuebeauty.net/yule/”]Example 2[/URL]
Resize the window to see the responsiveness of the system.

The way I see it, internet/computer speeds are fast enough these days that if you can specify a layout system that works exactly how you want it to, and will render the same across all platforms, in under 50kb, why not? Why remain a slave to the major browsers ability to implement a system that was poorly designed in the first place?

The most powerful part of this system is that anytime I want a new feature, I can simply implement it myself: I don’t need to wait for the next CSS spec. And so far, in addition to designing my spec in a way that actually makes sense, I’ve added some very useful features not found reliably in CSS, such as:

[LIST]

  • [*]

    The ability to easily align any element (including text) inside any other element, top/center/bottom, left/center/right.


  • [*]

    The ability to float elements inside a parent from the left, right, top, or bottom. Furthermore the ability to stack the elements into the smallest possible space


  • [*]

    The ability to set an element to fill remaining space in the parent, or split the space evenly with other filling elements.


  • [*]

    When setting widths/heights in percentages, the ability to specify percent of width, height, or of the smallest dimension (%w, %h, %s), allowing easy creation of square elements.


  • [*]

    The ability to easily set elements to be spaced apart evenly.


  • [/LIST]

    Finally, the system is accessible and degrades gracefully such that if javascript is disabled, the user will still have access to all of the content.

    So what are you’re thoughts on this method. Any possible pitfalls? Documentation for all of the features, as well as the source code are on [URL=”https://github.com/madisonbrown/yule”]github[/URL].

    to post a comment
    CSS

    6 Comments(s)

    Copy linkTweet thisAlerts:
    @mbrown3391authorAug 13.2013 — Sorry, here is the second example, which demonstrates stacking from the top, while minimizing height. The yellow boxes fill available height in the stack.
    Copy linkTweet thisAlerts:
    @jalarieAug 14.2013 — You saved on divs in your HTML file by putting containers in your XML file; so?

    And it doesn't work properly in Opera unless the page is full-screen.
    Copy linkTweet thisAlerts:
    @mbrown3391authorAug 14.2013 — Well its semantics... the content itself is not nested, you can see this if you view the page source. This means that the page is much more accessible using this method. And the XML containers are't tangible objects, they simply tell the layout engine how to place the real elements on the page.

    But that's not really the point... The point is, I don't think you would be able to recreate the examples using CSS alone.

    It is tested in Opera version 12.15. What version are you using? Obviously this is still in the early stages of development and there will be bugs to work out.
    Copy linkTweet thisAlerts:
    @cootheadAug 14.2013 — Hi there mbrown3391,

    [color=navy]It's time to ditch CSS... Thoughts?[/color][/quote]

    It's a very, very silly idea. :rolleyes:

    If you are really going to ditch CSS, why do you have this...

    [color=navy]
    <link href="style.css" rel="stylesheet" type="text/css">[/color]

    ...in the head section of all your example documents? ?

    You can't have your cake and eat it. ?

    [i]coothead[/i]
    Copy linkTweet thisAlerts:
    @mbrown3391authorAug 14.2013 — did you read the post? clearly not.

    I thought I might be better off ditching CSS altogether, [B]at least for page structuring[/B][/QUOTE]

    the idea is that each page has an HTML file containing all content, an XML file specifying how that content should be arranged on the page, and [B]a CSS style sheet used only for superficial styling[/B].[/QUOTE]

    Superficial styling means colors and fonts. If you look at the style sheets, you'll see that's all they do.

    Madison
    Copy linkTweet thisAlerts:
    @cootheadAug 14.2013 — did you read the post? clearly not. [/QUOTE]
    I will admit that I succumbed to ennui after the first line of your diatribe. :rolleyes:

    You asked for thoughts about [b]ditching CSS[/b] and I gave you mine. ?

    If you want any other thoughts of mine, then I would have to say that

    you should feel free to pursue any crack-brained scheme of your choice

    that will solve your problems with CSS.

    [i]coothead[/i]
    ×

    Success!

    Help @mbrown3391 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.4,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...