CSS Selectors as Superpowers 190
An anonymous reader writes "Simon St. Laurent writes in praise of CSS selectors: 'After years of complaints about Cascading Style Sheets, many stemming from their deliberately declarative nature, it's time to recognize their power. For developers coming from imperative programming styles, it might seem hard to lose the ability to specify more complex logical flow. That loss, though, is discipline leading toward the ability to create vastly more flexible systems, a first step toward the pattern matching model common to functional programming.'"
Completely agree (Score:5, Informative)
Re:Completely agree (Score:5, Insightful)
Anyone who has used JQuery will know how their power exceeds the original intention
...anybody who has used jQuery will know how powerful they could have been if only browsers had implemented them completely and consistently.
Meanwhile, anybody who has used CSS will wonder what the hell the original intention was, given the arcane kludges needed to produce popular web-page layout effects easily achieved using evil tables and frames, the lack of 'constants' to set standard colours and measurements.You know there's something wrong with a standard when Microsoft's broken box-model implementation makes more sense. However, that's not the fault of the selectors.
Its as if the designers* of CSS had never looked at a web site, used a DTP package, used styles in a WP package, let alone played with a Java layout manager to get ideas about what might work and/or be useful.
(* probably unfair - I'm sure it was a mixture of committee syndrome and the notion that you can define a standard without producing a reference implementation rather than individual failings).
Re: (Score:3)
...anybody who has used jQuery will know how powerful they could have been if only browsers had implemented them completely and consistently.
This used to be true a few years ago, but all modern browsers nowadays parse selectors quite similar. Even IE8 is not so bad (it understands CSS 2.1 selectors like :first-child and [attribute] etc.).
Of course things keep evolving all the time, so if you want to use cutting edge stuff, you might run into some things. But in general I think especially the selectors are amongst CSS' least problematic areas.
Re: (Score:2)
Fixed that for you. This has to be the most annoying part of it all. They really should have implemented the opposite where you required a special doctype to put the browser into legacy mode. Would have made everybody start to make their pages standards compliant much sooner.
Re: (Score:3)
On the other hand, this really forced devs to include the proper doctypes in their work, which is a good thing!
Re: (Score:3)
Meanwhile, anybody who has used CSS will wonder what the hell the original intention was
It was to provide an easier alternative to xhtml/xsl. Instead of the total separation between data and formatting that many programmers rooted for, it is a bastard compromise that was reached : HTML would still specify both data and formatting but formatting would "skinable".
Some days I think that we live anyway in a world of compromise and that it is true that HTML/CSS is easier to use in 95% of case, yet other days I wonder if in the end we are not doomed to come back to the original intent, after a lon
Re: (Score:2)
generate the formatted page from an XML content
Some web programming frameworks already work like that.
Re:Completely agree (Score:5, Interesting)
What box model would be best?
Serious question. I'm doing a specialist graphics app at the moment, and I was just considering this the other day. What's the important rect for a box?
Most graphics app use a rect that is halfway through the border by default, as a result of the concept of "stroking" the rect. CSS is very different, and as you say a bit broken, by default using outside the margin for position, and content rect for size. So there's no concrete rect for layout of a box at all in CSS. And then there's box-sizing, which could allow the concept using the same rect for positioning and size, but doesn't.
How would a designer prefer to think of the primary metrics of a box, for the sake of alignment, snap to grid, proportional resizing etc?
1) Margin rect
2) Outside border
3) Centre of border
4) Inside border (outside padding)
5) Around the content (inside padding).
Of course, "all of them" and "it depends" are rational answers. But not much use when deciding on default or standard behaviour.
Re: (Score:3)
Don't make it standard behavior.
E.g., instead of letting the designer specify "width", let him specify "content-width", or "outside-border-width", or "margin-width", etc.
And in case of conflicting specs (e.g. two or more conflicting attributes given) produce an error (don't choose a precedence order!).
Re: (Score:2)
What box model would be best?
One that allows me to discover BOTH inside and the outside sizes so I can measure BOTH what will fit in my box, and what my box will fit in!
Thanks jquery!
Re: (Score:2)
As far as I can see that's still not a best box model. It's mostly just different varieties of patching over what's broken. Those are just sizes, they're not rects.
outerWidth(true) does at least match the same rect as CSS left. But is setting/getting a rect by the outside of an invisible margin (that may or may not be collapsed) anyone's ideal metric?
Re: (Score:3)
What box model would be best?
I'd look on it from the perspective of "encapsulation": One person should be able to design what was in the box without knowing how it was going to be placed on the page, a second person should be able to place it on the page and align it with other elements without affecting anything inside.
That would work best if the primary size of the box included the inner margin/padding and border (which the box designer 'needs to know'), but excluded the outer margin (which the 'page designer' needs to match with ot
Re: (Score:2)
You're able to control how the box model is calculated in CSS3 using the box-model CSS property. You could standardize on the MSIE way, if you so choose.
Re: (Score:2)
You mean the box-sizing property. I already mentioned that in the post you're answering.
Re: (Score:2)
I always thought it should be the border, with padding pushing the content in, and margin pushing other content away.
it would make % sizes work more intuitively I think.
Re: (Score:2)
" given the arcane kludges needed to produce popular web-page layout effects easily achieved using evil tables and frames, the lack of 'constants' to set standard colours and measurements."
This, a thousand times this. Honestly, why the hell has CSS not been fixed? They could have easily added what was needed to make things a lot easier. but instead they force everyone to fight with it.
Re: (Score:2)
Re: (Score:2)
Rejoice brother, for the era of display:table-cell has begun (supported in IE8 and up, and IE7 is effectively dead, thank god). Nice clean semantic markup, but now with access to all the juicy table features like vertical & horizontal-block centering, shared column height, and automatic column sizing. (Good article: http://www.digital-web.com/articles/everything_you_know_about_CSS_Is_wrong/ [digital-web.com])
Re:Completely agree (Score:5, Insightful)
Things like SASS and LESS point out where the big flaws of CSS are. It's crazy we still don't have variables in 2013 by default, this has been at the top of the requested features list for what, 15 years now?
Re: (Score:3, Interesting)
Re:Completely agree (Score:5, Interesting)
And now your web server has to do PHP processing on every page and every style sheet, so your load goes up. So you implement some caching. Now you have two problems.
Re: (Score:2)
Re: (Score:2)
Yeah, I suppose you could do that. Or you could just use LESS or SASS, which basically do the same thing and give you a whole lot more.
Re: (Score:2)
...or you could just use the existing features in CSS and HTML (and javascript, if you feel like it), let people know when they're using a broken browser and why things look stupid, and let the complaining get it fixed.
Microsoft actually fixed some extremely broken things in IE after they realized that developers cared and that supporting standards enabled other browsers to do things that didn't work right in IE (I actually just got done reading some developer blurbs on their new Ajax Control Toolkit that m
Re:Completely agree (Score:4, Funny)
And now your web server has to do PHP processing on every page and every style sheet, so your load goes up. So you implement some caching. Now you have two problems.
3 problems.... php itself being one.
Re: (Score:3)
He's using PHP? I get the pitchforks!
Re:Completely agree (Score:5, Insightful)
Please don't burn me, I don't weigh the same as a duck...
Re: (Score:2)
It's crazy, but SASS and LESS also deserve to stay in their own separate play-place for now. It's important for these to continue to expand and develop, but in both camps there is constant movement and redesign, no clear stability, and no clear path of where certain features will lead. CSS, on the other had, is generally solid and not often updated. It has to remain rather slow and boring in order to maintain support for all the browsers and designers and companies who are relying on said stability. Variabl
Re: (Score:2)
That makes no sense. CSS could easily be fixed by a lot of the things that are already in SASS and LESS. They are not different tools for a different job.
Re: (Score:2)
I swear by LESS, but it isn't a standard and requires too much CPU (whether processed server side or client side), and it doesn't fix a model which makes it very difficult to do very common layouts.
Re: (Score:2)
So use a LESS compiler then: edit LESS-file, compile to CSS, test CSS locally, upload to server. Rinse and repeat.
Re: (Score:2)
That is exactly what I'm doing, using lessphp (http://leafo.net/lessphp/).
I'm using it both to generate some jQuery themes (https://github.com/vanderlee/Afterdark, somewhat old) and dynamically (with caching and "compression") in my own framework.
But it's not as convenient as just using static files would have been and most importantly; it still doesn't fix the box model.
Re: (Score:2)
I don't know if LESS has this, but with SASS and Compass, you can tell Compass to "watch" your SASS folder - when any files change, it automatically rebuilds your CSS. Quite nice for actively working in the SASS without having to go back and recompile every dang time you change something.
On the dev side, all of our SASS is compartmentalized into partials for that particular section "_toolbars.scss, _article.scss, etc" Our local configurations are set to compile the SASS to expanded CSS, complete with annota
Re: (Score:2)
Visual Studio 2012 Update 2 will auto-compile any LESS file as you type in it (I think it does COFFEE as well) into both .css and .min.css versions.
If it's a .NET site, then you can reference the css files in a bundle which will combine multiple .css or .min.css files into a single file, and will auto build a new one whenever one of the files in the bundles changes. Pretty slick.
Re: (Score:2)
Yes, so why can we not simply send the SASS to the browser?
Re: (Score:3, Insightful)
not true, there are clear defects in the tools that almost everybody agrees on (variables), plus the browsers don't support everything even though the specs are years old.
sometimes the tools really are bad....
Re:Completely agree (Score:5, Funny)
Tell that to the guy that has to build a house with a saw that has no teeth.
He will probably beat you to death with that saw. People that have no clue at all as to the problems with the tools or even how to do the task are the first to blame the craftsman.
Re: (Score:2)
Bad craftspeople have a definite tendency to blame their tools
...and bad software designers have an even more definite tendency to blame their users. Usability/clarity and appropriateness for the intended user base (in this case, graphic designers) is part of good tool design.
CSS smacks of being a hammer designed by someone who has never seen a nail.
Re: (Score:2)
The CSS property you're looking for is box-sizing. If you want modern browsers to use IE's box model where the width includes border and padding, use the value 'border-box'.
Yes - but is it supported by IE7...
If you want to yell at someone, yell at those folks still XP and IE8 (or earlier).
Unfortunately, such folks fall into categories like "clients", "customers" or "target audience" and its not such a good idea to tell them "piss off and come back when you've got a decent web browser".
This does all get better the further IE6/7/8 fade into history - if I were starting a site today I could at least ignore IE6/7 - but I'm still seeing significant hits from IE8.
Then new things come along: I was having trouble with 'background-size' recently (handy if you want
Re: (Score:2)
The CSS property you're looking for is box-sizing. If you want modern browsers to use IE's box model where the width includes border and padding, use the value 'border-box'.
Yes - but is it supported by IE7...
Does IE7 support the IE box model? I'm not sure, I'll have to get back to you on that one.
Unfortunately, such folks fall into categories like "clients", "customers" or "target audience" and its not such a good idea to tell them "piss off and come back when you've got a decent web browser".
That's true, it wouldn't be a good idea to tell them to "piss off". It would be better to just tell them that they are using an unsupported browser that no longer receives testing, and they can either upgrade their browser or pay extra to test on legacy software. That sounds a little better than "piss off".
Re: (Score:2)
Forget about IE7. Apart from some corporate environments with which you don't want to have to deal with anyway, nobody is using that browser anymore. IE8 is the absolute minimum these days. Just another year and non-HTML5 compliant browsers will be a thing of the past. Finally.
Re: (Score:2)
Unfortunately, such folks fall into categories like "clients", "customers" or "target audience" and its not such a good idea to tell them "piss off and come back when you've got a decent web browser".
A few years ago, I'd agree with you. Now? You can let those 3 clients go, you won't miss them that much. If you tell them to go piss off, they'll come back, no one else is going to support them either.
IF your business depends on old IE users for survival, you're fucked anyway, by definition.
Re: (Score:2)
No, not really.
jQuery does it, CSS is just the way jQuery is interfacing with the browser. CSS isn't really doing anything but making the situation more complicated and convoluted actually.
CSS + jQuery, like most things on the web now days was stumbled on, not designed. It was stumbled on because no one bothers to think about what they are putting into HTML and how it affects the future, they only pay attention to what they want in their browser for today. The end result is that most of the system is dec
Practically Worthless. (Score:4, Insightful)
Think about it. It's practically worthless. We might as well be compiling CSS + HTML + JS into an interactive PDF format for all the times we actually reskin entire sites. Even mobile stuff is suspect -- I mean, yeah, I can have 10 different images to serve depending on the size of the display, and I automate that image asset generation... Then what? I make the images be CSS backgrounds? Isn't that defeating the point of separating the style from the content? Go the other way: Actually put the content wholly in the HTML, and only use CSS to style everything. Yeah, great, I can sort of reskin for printers and mobiles, but where's the detection mechanism? It's on the server side... Thus conflating the whole model, view, controller and the presentation, content, style, etc. I mean, JS to manipulate the view -- So, what, a segmented controller? CSS3 Animation instead? Oh, so that's a style thing now. Bah, whatever. A rose by any other name...
The problem is that designers would love to think these problems can be isolated and are separable. The reality is that they are not. Concentrating on making your CSS super flexible with selectors is merely mental masturbation. If it weren't then folks would be making CSS libraries for pulling off common styles and effects. Go to the "poster child" of CSS: CSS Zen Garden, and see for yourself. Tons of #id tags, tons of different designs, no one really taking any two designs and combining them with ease...
The reality of the situation is that the next person who comes along will just scrap the whole thing and re-make the design again anyway (yes, even if that person is you). Might as well be compiling it all down into a low level colored shape display system, that way we can implement CSS and HTML and even new markups atop it, instead of waiting for OVER HALF the age of the web just to move from HTML4.01 to HTML5...
CSS is great, unfortunately designers can't use it (Score:4, Insightful)
CSS is great when used properly (although, somewhat hereticly, I would kill for definable constants a-la 'color: PRIMARY_WEBSITE_COLOR;' without resorting to dynamically writing the CSS ).
Unfortunately graphic (website) designers are completely shit at using it. Even simply understanding when they should use an ID and when they should use a class seems to a'splode their brain, "huh, what is wrong with using this same id a bajillion times in the page". Don't even try telling them that "redtext" is not a good classname. Heck half of the time it's ".span1"!
They don't even know (even after telling them half the time) that you can use multiple classes on a single element, let alone combine selectors, everything is a single ID or classname to them. The amount of copy-paste in most web designer's stylesheets is simply offensive, all because their brains don't allow them to modularise their desires into useful reusable CSS classes. Cascade? Inheritance? These are foreign words to the average website designer.
There is no point telling a designer how they should can make their CSS better, they just won't understand. Worse, if the programmer, who does know how to use CSS as it was intended, attempts to fix their stylesheets (or worse, cut up their photoshops into proper HTML and CSS), the original designer just won't understand how to do anything in the stylesheet anymore.
Re: (Score:3)
Unfortunately graphic (website) designers are completely shit at using it. Even simply understanding when they should use an ID and when they should use a class seems to a'splode their brain, "huh, what is wrong with using this same id a bajillion times in the page".
If CSS did what it said on the tin - separated content from style and layout - then graphic designers wouldn't have to bother their little heads about this sort of thing because they wouldn't need to touch the semantically-marked-up HTML.
Unfortunately, (a) CSS doesn't do what it says in the tin - changing the layout inevitably needs including exactly the right permutation of DIVs in the markup because CSS doesn't have any way of doing what every half-decent DTP package since PagerMaker 1.0 can do: defining
CSS should be a programming language (Score:4, Interesting)
Intellectually, I know that if it were more complex, there's no way it would have seen widespread adoption, and that markup is actually still complicated for many people. I can even look back at the early days of the web, when Marc Andreessen butted heads with Tim Berners-Lee about the media tag meant to display images, sounds, video and anything else and said, 'Screw it, you guys take too long to decide anything and it's over complicated, here's an img tag, done.' - and I can see how simple beats theoretically perfect and well designed.
However, we're already at the point of widespread adoption now, and it's a good time to have a new css that actually is a programming language, with flow control, dynamic calculations of element values, and so on. This is what we need to provide real separation between the document and how it looks. Anyone experienced enough to write non-trivial web applications that are meant to be run on a browser, tablets of varying sizes (including accounting for reorientation), and even cell phones knows that it's unrealistic to use a single page - you get sent to the 'mobile' variant of the page or elsewhere.
Css has been around for 16 years and it still lacks the ability to easily declare a completely separate layout based on display height or width, something like "If width is less than _x_, use this css, else this" or "set width equal to - 30". If you want those things now, you have to use javascript, and it's sometimes pretty awkward - like calculating the width of an element filled with content prior to displaying it.
To you folks who cite javascript to fix this, realize that css no longer manages the document display at that point, the javascript does. That means that css is missing something required to manage a display. It can only do some of it's job.
- side thought; I'd be happy if css allowed javascript within the css. Assign values based on closures or predefined functions. Simple fix -
Re: (Score:2)
Also, to you folks who are pants-on-the-head retarded, and think that html, css, and js equals an mvc, you are incredibly wrong. Javascript plus css is what defines the view, and that goes for all javascript outside of a few frameworks like Backbone that actually implement a real Controller pattern.
Re:CSS should be a programming language (Score:5, Informative)
Actually, you can do that. I do it all the time when I use responsive web design. Here's some sample CSS code:
@media screen and (min-width: 501px) and (max-width: 750px) { /* Put styles in here to reformat the page for larger tablets or small desktop resolutions */
}
@media screen and (max-width: 500px) { /* Put styles in here to reformat the page for mobile devices and small tablets */
}
@media print { /* Put all of your styles in here to format the page for printing. */
}
There is no JavaScript at work here. If you loaded a page utilizing this code in Chrome or FireFox (or IE10), disabled JavaScript, and resized the browser to make it smaller, you'd see the page slowly transform from a desktop version to a tablet version to a mobile version. (A good example of this is the Boston Globe's website: http://www.bostonglobe.com/ ). I can set styles for HTML elements and override them if certain conditions are met (max-width is between 2 values, screen resolution is a certain amount, print vs screen, etc). It might not be "if-then" statements, but it has the same effect.
Re: (Score:2)
I don't have mod points right now, so let me just say thanks for pointing that out. The Boston Globe's site is really neat when you re-size.
Re: (Score:2)
I have used media queries, and they are a great addition that gets us another step closer, but they're not the end-all, be-all. Once all the mobile devices can settle down and give us consistent and sane implementations (like not downloading every image, even those outside of the @media block), we'll be even better off, but it's still not a solution to each of my issues. Providing for statement evaluation, flow control, variables, and so on will.
As someone who's actually written desktop apps, every time I
Re: (Score:2)
Css has been around for 16 years and it still lacks the ability to easily declare a completely separate layout based on display height or width, something like "If width is less than _x_, use this css
Erm... heard of media queries? They do exactly this.
@import url(narrow.css) (min-width:800px);
This loads stuff from narrow.css and applies it if your window is less than 800px wide.
Re: (Score:2)
Actually, I see CSS as it stands now as the sendmail problem. Trying to accomplish in markup what amounts to an if/then statement - much less flow control - is incredibly complex as the language is not well suited for it. At some point, it's easier to write a program to do it. In comparison to what a markup language would need to be to accomplish my daily goals while writing a webapp, a programming language would be more succinct without losing readability, explicit as opposed to derived, and easier to o
Relational? (Score:2)
Why not leverage people's existing SQL knowledge and create a relational-friendly DOM? There will still be tree-oriented nesting, but special functions and views can assist with that.
The problem is (Score:2)
CSS selectors actually work?! (Score:2)
Every few years I crawl out of my sandbox and absorb any useful changes in the browser scene.
The last time I tried CSS selectors every one I wanted to use either didn't work at all or worked great until I tried the same thing in a different browser.
Re:!Like (Score:5, Informative)
Re:!Like (Score:4, Funny)
Bollocks. CSS was designed to separate styling from structure in web pages. It does this admirably, and only needs to be a declarative language to do so.
Bollocks. Every configuration file should be Turing complete. -- The Sendmail Authors.
Re: (Score:2)
if it only included a #define....
Re: (Score:2)
You are confusing structure with layout. Tables are a used to define document structure, when the data to display is tabular. to use tables to layout the document when the contents of the table is not tabular data is plain wrong!
Re: (Score:2)
You're confusing the point.
The point is to get a job done. You're just adding unneeded semantics based on a broken philosophy. CSS is not better in several instances. Table based layouts are the proof of that. Instead of recognizing shortcomings, you're ignorance shows through as you just keep parroting the same old tired line ... which just goes to illustrate that you are having a religious debate about your preferred language rather than a discussion of technical merits.
Re: (Score:2)
If you think CSS interferes with structure, you don't understand what structure is. CSS is only about how things look, nothing more. HTML used to do style too in a distant past and there are a few remains of that still in there (some form elements for example have their own style which can't really be changed through CSS). But the other way around? No way.
Re:!Like (Score:5, Insightful)
CSS alongside 2 basic layers, regular code and HTML document itself, only creates additional unnecessary third layer of shit that eventually may introduce problems, as soon as someone starts playing with it
That's like saying MVC is unnecessary, and not just putting all your code in a single class/module/namespace may introduce problems. There are people that say that, but they are novices.
HTML5/CSS/JS is equivalent to MVC. The "VisualBasic" type people would tend towards trying to put everything in their HTML rather than the other way around.
Re: (Score:2)
Re: (Score:2)
Um, no. MVC is a design pattern (i.e. a set of concepts for programming) that can apply to any language, CSS is declarative style markup (that apparently some people think should be the next programming language) that depends upon another markup language (HTML, XML).
I'm happy that you know that. It's a shame you don't have the comprehension ability to see that nothing in my post said otherwise.
I think you should look up MVC.
I thing you should try teaching your grandmother to suck eggs.
Re: (Score:2)
Um, no. MVC is a design pattern (i.e. a set of concepts for programming) that can apply to any language, CSS is declarative style markup (that apparently some people think should be the next programming language) that depends upon another markup language (HTML, XML).
No. He got it right.
Done properly, HTML is semantic. Its data. Its not a neat paralllel to a model , but its in the ballpark.
CSS is the layout, its a view. It takes the model and presents it.
And Guess what Javascript is?!
Now your getting it!
Re: (Score:2)
While that has nothing to do with the original point the person was trying to make, keep in mind MVC is a very specific pattern, and the fact you have a model, a view and a controller is only a part of it. How you use them is also part of the pattern.
You can have a model, a view, and a "controller" and end up with a MVP, an MVVM, or a variety of other patterns that have these 3 components in one form or another.
Re: (Score:2)
And that really shows that while you understand the concepts of MVC, you don't understand what HTML actually is or how MVC exists in the real world.
HTML is both data and view. CSS is just sorta view. and javascript is just control (usually coupled with a backend component to complete this part of MVC).
The real world and the theoretical/ideal are entirely different.
Re:!Like (Score:5, Informative)
You have no idea what you're talking about. CSS (and HTML for that matter) have *nothing* to do with programming. CSS is merely a way for designers to code a layout, nothing more, nothing less.
I do agree CSS could have been a lot better and there are definitely some errors which needs fixing, but the general idea of separating mark up and layout is a sound one and selectors is one of CSS' best features.
No , sorry. (Score:2, Interesting)
All non progammatical web code has to do is describe a page. There is no reason on earth for requiring 2 completely different formatting languages - HTML and CSS - to do this. CSS is just a nasty hack on top of HTML which was already a hack anyway and along with embedded javascript its turned web coding into a total dogs dinner.
Re:No , sorry. (Score:4, Insightful)
You're crazy. CSS and HTML are completely unrelated languages and technologies. None is a hack on top of another. HTML describes the structure of a document, CSS defines how things look. It's that simple. They require a different syntax because they are used for different things. And they're both very successful at what they're trying to do. Sure there are problems, sure there are things wrong with it, but show me something perfect. There are two types of languages you know: ones everybody complains about and ones nobody uses.
I have no idea what you mean by "embedded Javascript", but Javascript is the programming language of the web. Contrary to HTML and CSS, Javascript is a "real" programming language by any definition. Without it web applications would not be possible and the web would merely be a document system. Instead its the world's largest application platform, allowing users on any device to use your applications. If you are a web developer and you think that's not exciting then maybe you should think of switching careers.
Unrelated technologies??? (Score:2)
Wtf are you smoking? HTML used to do presentation. And there's no reason it still can't. Please feel free to give the exact reason for CSS having an entirely different syntax and structure to HTML when XML which can store far more complicated data than CSS manages to have a pretty similar one.
Re: (Score:2)
HTML used to do presentation
Yeah, over a decade ago. How is that even remotely relevant to the modern web?
And there's no reason it still can't.
All the formatting tags are dropped in the latest versions of HTML. You can only use them if you're stuck in the past.
Please feel free to give the exact reason for CSS having an entirely different syntax and structure to HTML when XML which can store far more complicated data than CSS manages to have a pretty similar one.
XML has a lot of cruft. Look at the difference in size between a JSON file and an XML file containing the same data. The same thing would apply to style sheets written in XML.
Also: why do you think it would be beneficial to have more or less the same syntax for two completely different things? What would you gain b
Re: (Score:2)
How so? Care to elaborate or provide an example?
Re: (Score:2)
How so? Care to elaborate or provide an example?
http://www.w3schools.com/tags/tag_font.asp [w3schools.com]
Re: (Score:2)
Sure, HTML used to include tags for styling in the past. There was a time before CSS was invented and people wanted to make things look pretty after all. But these sort of tags have been regarded deprecated for at least a decade now.
Re: No , sorry. (Score:2)
Oops. (Score:3, Insightful)
First, you lose credibility for linking w3schools.com. Professional web developers wouldn't be caught dead referencing them. [w3fools.com] Second, you're referencing a tag that's deprecated because of CSS. Professional web developers wouldn't be caught dead using a font tag (or any other stylistic tags for that matter).
Re: (Score:2)
That page has 5 pieces of red text saying that the font tag is not supported in HTML5. It tells you to use CSS instead. It says that it was deprecated in HTML 4.01. The font tag is an example of people realizing their mistakes, not a reason to bash modern HTML. Even W3Schools, with all of its problems and outdated tutorials, makes sure people know that.
Re: No , sorry. (Score:2)
Re: (Score:2, Funny)
This post is awesome! I'm saving it for later, thanks!
Re: (Score:2)
All non progammatical web code has to do is describe a page. There is no reason on earth for requiring 2 completely different formatting languages - HTML and CSS - to do this. CSS is just a nasty hack on top of HTML which was already a hack anyway and along with embedded javascript its turned web coding into a total dogs dinner.
The purpose of HTML is to organize data for display - and possible return via a submitted form. The purpose of CSS is to control the presentation of that data. HTML was invented first, and originally had to shoulder some of the responsibilities of CSS, but CSS is now the preferred presentation control medium, not least of which is that it makes it possible to "skin" HTML to adapt it to multiple display devices and/or view preferences.
JavaScript exists to allow dynamic manipulation of client-side data, displ
Re: (Score:2)
CSS isn't a nasty hack, it's a necessity. Take a look at CSSZenGarden.com. Every time you switch to a different theme, the HTML remains the same. All that changes is the CSS file (and the images that it references). To do that with plain HTML and no CSS, you would need tags or attributes to represent each display style. This would mean changing the look of a page would require completely recoding it instead of simply updating the stylesheet. If you wanted to, for example, make all links red instead of
Re: (Score:2)
"This would mean changing the look of a page would require completely recoding it instead of simply updating the stylesheet."
And it would be impossible to update the syntax of HTML to allow one piece of HTML to reference another piece in a seperate file why exactly?
Re: (Score:2)
I don't think so. The fact that it's code doesn't make it programming.
Re: (Score:2)
I guess you're right. I was thinking of things like Turing-completeness, but I agree that is not actually necessary to make something a programming language. A player piano isn't a computer, but making a piano roll still is a form of programming.
Re: (Score:2)
The fact that it is interpreted by the browser and applied to the web page layout does.
No, it doesn't. CSS is a description language, not a programming language. It just maps elements to the layout of said elements. Calling CSS a programming language would be akin to claiming, the mapping of numbers to colors in a paint-by-numbers would "program" the picture.
Re: (Score:2, Informative)
If that's what you think, then you don't understand why CSS and HTML are separate languages. The implementation is by no means perfect, but its a very good example of Separation of Concerns (separating content from presentation, and in javascript's case, both of those from application logic), something that all too many 'programmers' don't seem to have any idea about. Then again if you're one of those programmers who see SOLID principles as over-engineering then I can understand why you might think that its
Re: (Score:2)
CSS is a DSL for styles primarily. It could be used for other stuff as well. There are libraries available in Java. However, I do not know of any C++ library. But google returns just a lot on the topic for "CSS c++ library"
Re: (Score:3)
Yes. Qt will let you style the GUI [qt-project.org] with what is effectively CSS [nokia.com].
Re: (Score:2)
Yes, I am using it for an internal XML dialect that need styling and for which HTML is not appropriate. We use the Apache Batik internal CSS processor (because we are using Batik for their SVG support, no need for a duplicate CSS processor independent of Batik)
Re: (Score:2)
Why has functional - which is only midly declarative anyway but we'll let that slide - taken over the world like its proponents constantly tell us it will?
Don't you mean "why *hasn't* functional programming taken over the world"?
Anyway, it has. It's called Javascript and it's *huge*.
Re: (Score:2)
It has the "function" keyword duh!
Re: (Score:2)
I know you're mocking, but in Javascript a function is a first class citizen. You can pass functions as parameters, return functions, keep them in a variable, create them at run-time. The fact Javascript has a curly braces syntax doesn't mean it can't be a functional programming language.
Re: (Score:2)
The fact Javascript has a curly braces syntax doesn't mean it can't be a functional programming language.
Actually the thing that makes a functional language a functional language has nothing to do with curly braces. The defining principle of functional languages is that you have to have special hacks built into the language that technically violate it's functionality in order to make it do anything -- eh -- functional -- due to the fact that side effects are the only useful way to get anything done.
Re:Is this a joke? (Score:4, Informative)
Javascript is much more a functional programming language than a procedural one. It's by no means as pure as Haskell, but this also allows it to be useful.
I suggest you read up on some of the articles by Douglas Crockford, who does an awesome job of explaining the true nature of Javascript to the world. This is a good starting point [crockford.com].
If you don't believe Javascript is indeed a functional programming, here is a Google Talk by the same Douglas Crockford explaining how to do monads in Javascript: http://www.youtube.com/watch?v=b0EF0VTs9Dc [youtube.com]
Re: (Score:2)
If javascript is a functional language (because you can do monads?), then I guess C is also a functional language.
I think the definition of functional programming languages is more about what you can't do than what you can do - since they're all turing complete...
Hell, javascript functions don't even return a value by default. To me that screams *not a functional language*.
Re: (Score:3)
It sounds like your'e confused. And I can't blame you, because there are *a lot* of different languages and syntaxes involved in creating a web application these days and it can be challenging to grasp it all. It helps to separate things in your mind. Even though the syntax of e.g. a JSON file may look a bit like a CSS file, they are completely unrelated. Make sure you know what you're working on (structure, style, client side logic, server side logic) and only concern yourself with the things that are rela
Re: (Score:2)
No, a JSON file looks nothing like a CSS file, it looks a lot like a chunk of javascript though....
Re: (Score:2)
You can't deny there's a very similar syntax going on (blocks of key:value pairs encapsulated by curly braces). I believe Crockford himself even said he came up with JSON after staring at a CSS file and realizing it looks a lot like a Javascript object.