Is there a business reason for striving for pure CSS layout?

后端 未结 21 1091
情深已故
情深已故 2021-02-02 08:30

It seems like every time I try to create a pure CSS layout it takes me much longer than if I\'d use a table or two. Getting three columns to be equal lengths with different amou

21条回答
  •  情深已故
    2021-02-02 09:16

    Since this is stackoverflow, I'll give you my programmer's answer

    semantics 101

    First take a look at this code and think about what's wrong here...

    class car {
        int wheels = 4;
        string engine;
    }
    
    car mybike = new car();
    mybike.wheels = 2;
    mybike.engine = null;
    

    The problem, of course, is that a bike is not a car. The car class is an inappropriate class for the bike instance. The code is error-free, but is semantically incorrect. It reflects poorly on the programmer.

    semantics 102

    Now apply this to document markup. If your document needs to present tabular data, then the appropriate tag would be

    . If you place navigation into a table however, then you're misusing the intended purpose of the
    element. In the second case, you're not presenting tabular data -- you're (mis)using the
    element to achieve a presentational goal.

    conclusion

    Whom does this hurt? No one. Who benefits if you use semantic markup? You -- and your professional reputation. Now go and do the right thing.

    提交回复
    热议问题