Home >Web Front-end >CSS Tutorial >Is There Too Much CSS Now?
Front-end developers have been eager for many features for many years - centering methods in CSS, style encapsulation, element aspect ratio settings, finer color control, selecting elements based on child element attributes, managing specific levels, making elements respond to parent element widths... and so on.
Now, we get what we want and even get more, but some people are beginning to question - do we have too many CSS now?
In the past, front-end developers' work revolved almost entirely around the limitations of CSS. For example, use clearfix hack to clear floats, use 100% padding hack to create square divs, not to mention randomly applying irrelevant attributes to trick Internet Explorer into executing your commands.
At the time, the browser was a cunning enemy and needed to be defeated by pure skill and mysterious spells. Nowadays, the perfect attribute is there, just copy and paste on MDN.
Really care about the developers' feelings! I know, I didn't believe it at first. But I do a CSS status developer survey every year (and by the way, it’s in progress now – get involved!), and I know that the browser development team will use the findings (and many other data points) to determine their roadmap. Apart from that, Google also funded my investigation and even hired Lea Verou to take charge of selecting this year's investigation questions.
It's not just Google. Blowing Safari and Apple (sometimes should) has become a fashion, but you can’t deny Jen Simmons’ enthusiasm for listening to developers and improving the web.
Browser manufacturers are not only improving their own CSS; they are also collaborating across competitive boundaries through initiatives such as Interop 2023 to help reduce inconsistencies and incompatibility among browsers.
Too many good things?Lea and I considered many features, but also rejected some. Some of the features we
do not include:linear()
Easing function, which allows you to define easing curves more finely. env()
function, which allows you to use variables defined by your browser or device. scrollbar-width
property, which helps control the appearance of the scroll bar. margin-trim
property, which allows you to control the margin behavior of container child elements. All of these can be very useful and will be big news in the past when CSS shortages are in the past. But in today’s context, they have to compete with larger announcements (such as has()
selectors or CSS nesting!).
As Silvestar Bistrović writes, he is “not that excited” about all these new CSS features. Sara Soueidan responded on Twitter that she was concerned about “purpose, not how dazzling a feature looks at the moment.”
This seems to be a negative attitude, but I think it is understandable. No one can count on keeping up with so many new features!
Another unexpected (or maybe intentional?) consequence is that the more complex CSS is, the higher the barriers any new company looking to develop a browser engine faces—not to mention maintaining and documenting the extra workload of all these new features.
There is also a very reasonable concern that CSS may be expanding into areas where it is not very suitable for handling. Sara Soueidan also pointed this out when reacting to the experimental implementation of the new CSS switch (this is a ticket to discuss it):
Many have made a very reasonable point that this behavior is best handled by a new HTML element rather than managing the switch state purely through CSS, and that CSS may not be the best medium to ensure that accessibility issues are properly addressed.
This is often considered a good thing when CSS takes over content that was previously processed through JavaScript, as it usually reduces the amount of code the browser needs to load. Therefore, I am cautiously optimistic about the CSS switch and believe that the CSS task force will properly handle the community’s concerns. But maybe one day we will start to worry that CSS may be extending beyond its boundaries and infringing on HTML and JavaScript's duties.
Maybe this is what needs to be changed: maybe we should give up CSS developers must understand all CSS expectations?
This expectation stems from the time when CSS was once considered an afterthought, a nasty grammar you have to learn to turn your buttons into blue and bold according to the client’s request. But I think we need to accept that today’s CSS may be too large for one person to master, especially outside other front-end tasks.
As Michelle Barker said:
This is my final conclusion. I've accepted the fact that I probably never use — even know — all possible CSS features. And this is still from the person who conducted a survey on CSS!
But these new features are certainly useful for some people. Someone will write blog posts about them, create cool CodePens with them, and speak on them. This guy will be a cool, young, energetic developer with all his hair still. In other words, it won't be me - that's good.
Maybe you are worried that this new developer will be overwhelmed by having to learn too much at once. But remember that what they don't have to learn is replaced precisely because of these updated alternatives. I know I'll accept this deal anytime.
But think about it: over the past few years, we have not only seen a significant increase in the number of devices that need to adapt, we are also beginning to realize that each of us consumes networks in slightly different ways, which may be due to disability, current environment, or simply personal preferences. Shouldn't CSS adapt to this new reality?
Now, I have to admit that it all makes me feel a little nostalgic...so forgive me, I'm going to clear a few floats just for old memories.
As I mentioned, the annual CSS status survey is now open. Whether you think there is too much CSS or not, this survey is a great way to let browser developers know what you feel, so if you have 10 minutes, fill it in.
The above is the detailed content of Is There Too Much CSS Now?. For more information, please follow other related articles on the PHP Chinese website!