14 ms·
The mere fact that a site like this can exist and not be a joke is proof that CSS is still badly broken. I should be able to center things by writing: foo
by lisper 12y ago
The mere fact that a site like this can exist and not be a joke is proof that CSS is still badly broken. I should be able to center things by writing:
foo {
align: center;
valign: center;
}
- cyphunk 12y agoEvery 4 years: "lets check if latest css can center dynamic sized things without a bunch of #container_of_container cruft". Just stick with: <table height=100% width=100%><td valign=center align=center> And what the hell does "margin: auto" mean? I'd like to hear some print designers using that in normal conversation. "oh and also i'd like these margin's auto'ed". At this rate the table tag is going live longer than the copyright on mickey mouse.
- psychometry 12y agoNo, use divs and table-cell display values if you want to have non-tabular data displayed like a table.
- cyphunk 12y agoIndeed I have non-TABular data and yet I should use TABle-cell? I'll just stick with the actual <table> then. cleaner. But the real problem is "use divs". plural. so already breaking the #container_of_container cruft rule. I'd rather write some javascript with overly nested callbacks and leave the html clean. thanks.
- davesque 12y agoYeah, it's obnoxious when people get up-in-arms about specifics. But, you have to admit that it's correct. Why use explicit tables when you can use style overrides to get the look you want and your HTML markup is more meaningful to robots?
- TeMPOraL 12y agoBut then just admit it, you broke the web separation of concerns rule ("HTML is for content, CSS is for layout"). Which is load of nonsense, if you ask me, but people seem to treat it as a kind of religious dogma.
- davesque 12y agoDo you mean the requirement for a container `div`? If so, IMHO, that is the most routinely broken "rule" in web page design that I can think of. It should be obvious that the technologies involved in web pages are not perfect. I'm not claiming otherwise. It's a question of trade-offs. You're going to break the HTML is content convention whether you use a `table` element or a `div` element with "display: table". So why not just go with the one that's more correct? It's up to you either way I guess.
- RubyPinch 12y ago<table> is content, table-cell: is presentation. Semantic tag use matters because some people are blind and their screen reader will start randomly start talking about some structure that makes zero sense in context
- baddox 12y agoI understand and agree with the general argument, but is it actually true that screen readers for the web are that naive? I would expect them to render a page (like with WebKit) and try to figure out the layout of the page, which things are actually visible, etc., or at least use heuristics to figure out what is and isn't content (in the same way that Readability-esque algorithms presumably do).
- Figs 12y ago> Readability-esque algorithms presumably do They look for the div with the most text/paragraphs in it and assume that's the article. At least, that's what the open source ones I looked at a while back do -- the proprietary ones that force you to go through their own server could use other tricks.
- extra88 12y agoThe browser, not the screenreader, does the rendering, figuring out what's visible, etc. The results, an "accessibility tree" which is sort of a subset of the DOM, are then presented through an accessibility API to screenreader software. Screenreader software is pretty naive, there might be some that initially assume a table is being used for presentation, not data, if it lacks good semantic structure (e.g. no <th> header elements). Case by case, it's hard to tell in which way the author is bad at their job, using a table for presentation or poorly marking up a table for data. The stakes are much lower for Readability-esque algorithms, when they fuck up the user can just go back to the site's native presentation; screenreader users don't have that choice.
- rtpg 12y agoJust a practical consideration, but the HTML table tag is actually a lot more restrictive (<table> can only contain <thead> <tbody> or <tr>, so no wrapping span to regroup some table rows) than using <div>s. Can be important depending on third party libs.
- robin_reala 12y ago(…and <tfoot>, <colgroup>, <caption>)
- madeofpalk 12y ago`display: table` and `display: table-cell` are just layout algos, commonly used for creating a table-like layout.
- psychometry 12y agoYou'd rather write unncessary Javascript and/or three nested HTML elements (table > tr > td) instead of two divs and some simple CSS? Man, I'd hate to be one of your clients since you don't really understand front-end development.
- supercoder 12y agoI also find it crazy how there was a huge campaign to remove use of the table tag for layout. 'It's non semantic! You're mixing layout and content!' people would cry over and over. .. But then we've ended up with bootstrap and it's grid layout, where we're doing exactly that, and for some reason it's perfectly fine.
- cyphunk 12y agoand I wonder how the <ul><li> somehow survived unscathed and free from the semantic witch hunt of yore. shouldn't we replace them with: <div style="display:list-type; type-of-list:unordered"> <div style="display:list-item;"> ?
- lucideer 12y agoThis comment doesn't make any sense. A list is a thing, just as a table is... What are you trying to say?
- tjic 12y agoDown vote for "doesn't make sense". It made perfect sense to me. The phrase you were looking for is " I don't understand what you're saying."
- wtallis 12y agoThen perhaps you would like to explain it? The most meaningful interpretation I can see is that the commenter completely misunderstood the nature of the "semantic witch hunt" to which he referred. It seems charitable to assume that something was lost in translation and to ask for clarification rather than to assume that the commenter was just saying something stupid.
- exodust 12y agoVery true, and such charity doesn't help the discussion. Insisting on the polite path, "I don't understand" instead of "your comment makes no sense" wrongly assumes that all comments written on forums are carefully considered and fact-checked before posting. It's taking the long way to resolution of that point, and you might never get resolution if bogged down in overly-polite discourse for fear of being "negative".
- nness 12y agoComparisons to print designers misses the biggest point about web design, that is that we have no way to guarantee a width, a position or even choice of font. Print designers know an A4 page is always 210x297mm, web designers have no idea what to expect.
- zaidf 12y agoBut if you are still using the table tag for anything but tabular data, you're living in the 1900s and arent cut out as a modern day web designer /snark
- ommunist 12y agoYes, you are right. As long as people are using HTML mail, tables for layout are the only way to go.
- kagamine 12y agoI have a gift for you! : /s
- dredmorbius 12y agoYou just made the best case for Markdown email that I've seen. Author email in straight text? Markdown is what you're writing already. Author it in WYSYWIG/GUI clients? You only care about presentation.
- rimantas 12y agoOk, now make it repsonsive, e.g. one column should be below the other on the narrow screen.
- RobertKerans 12y agoBy the same dint, web designers don't talk about paper weights and finishes. It's crackers, almost as if the two sets of designers are using different technologies.
- hobarrera 12y ago> And what the hell does "margin: auto" mean? It means "calculate the margins automatically according to available space". Nothing complicated about that. Print is quite different from web. The most noticeable difference is that paper cannot be resized, nor does it adapt it's content when you rotate it.
- protonfish 12y agoYour example does not align vertically, so I am not sure what you are trying to prove. This CSS will put something in the center of your screen quite easily position: absolute; top: 50%; left: 50%; Is that so hard? Having poor CSS skills is not the same as CSS being broken.
- cyphax 12y agoUnfortunately, that's telling your div to start halfway. Following your suggestion leaves me with an element with its top left corner in the exact center of the containing div. I'm not a fan of CSS due to issues like this. It falls in the same line as issues where, for example, paddings and margins (and borders) are added to the size of your div rather than subtracted. There's a solution for that that makes sense nowadays but by the time that came about, I'd already stopped liking CSS.
- statictype 12y agoAt least you can do horizontal alignment by throwing in the towel and using <div align='center'>. Vertical alignment is the real killer.
- woah 12y agoThe mere fact that the site exists means nothing. Any problems around centering have been completely solved by flex box. If you're targeting obsolete browsers, you're going to have to expect to do some legacy hacks.
- rtpg 12y agoIt's actually a consequence of the CSS box model, which makes a lot of other things simpler, and means that figuring out how to position things isn't turing complete or something. I think the secret is that maybe 10% of CSS writers actually have read more than the bare minimum to getting their layouts to work ( I am not among them, mind you).
- pcwalton 12y agoYou're in luck. foo { display: flex; /* opt into the new box model */ justify-content: center; /* "align" */ align-items: center; /* "valign" */ } Vendor prefixes may or may not ruin your day (for now), but the spec is there and is exactly what you want. CSS is no longer "badly broken" if that's your metric.
- tedunangst 12y agoSweet. I figure only 15 more years until we get two column layouts working, and then we'll finally be able to publish like it's 1979.
- sondr3 12y agoI'm pretty sure flexbox can solve two column layouts very well, just not with one continuous piece of text.
- visarga 12y agoIt would seem there is less than 92% support for flexbox yet.
- indubitably 12y agoBetter go back to print, then.
- freshyill 12y agoSo fall back to display: table for the garbage browsers. This is not difficult stuff.
- pcwalton 12y agoCSS multicolumn layout is four years old. It's implemented in all the major browser engines, and many popular sites like Wikipedia use it. http://www.w3.org/TR/css3-multicol/ http://www.w3.org/TR/css3-multicol/
- deleted 12y ago[deleted]
- asw13 12y agop
- hawleyal 12y agoPretty simplistic/naive.
- talmand 12y agoA tool is not broken if people insist on using it in ways it was not designed to be used. The fact that you say there is no easy vertical center, of which I disagree, doesn't make it broken. It means it's missing a feature you wish existed.
- 3minus1 12y ago> it's missing a feature you wish existed. indeed, an extremely basic and fundamental feature than any site that implements popups could use.
- talmand 12y agoAnd yet, popups seem to work just fine without this missing "basic and fundamental" feature. There are numerous ways to handle the problem that is legitimate and valid.
- ChuckMcM 12y agoHeh, generally any time there is a site with a name that is a search query it is an SEO hack. I was surprised it wasn't plastered in ads :-) That said, centering (and typography) in CSS and elsewhere is that you mix passionate people with a really hard problem and you don't get answers, you get a lot of debate. I used to read the alistapart mailing list and it was intense at times. Suffice it to say that when the content of part A and part B are different by 1 screen pixel, and you're centering, do you assume +1 pixel or -1 pixel? (You don't get 1/2 pixel resolution) a typically large debate
- sonthonax 12y agoIt really isn't. There's this misconception that CSS is a display language; it's actually designed as a typesetting language that must degrade nicely.