- or
- ? This is a game problem. So far, no one can give a clear answer to this question, not even me. It is true that
- element, this div seems a bit redundant, but sometimes in order to match the gorgeous design, an extra layer of tags means One more layer of variation (some people also use span in the a tag). The inherent advantage of div without any original attributes is unmatched by other tags. I just want to illustrate one thing with this proposition, that is, we should realize that in addition to
- , there is also the writing method of
- , similarly It has good structure and semantics, and eliminates a layer of nesting. When we don’t need to worry about gorgeous art, can we also make the structure more simple?
This proposition can actually be extended to: "Not all content needs block elements as containers", "Not all links need other elements as containers", for example, many pages have "More". Some people write "
or . Is it necessary for these "containers" to exist when they only contain an tag? Will writing directly as destroy the structure? Will it lack semantics? Will it affect the layout? If you think differently, you may gain something different.
4. Also achieve "separation of structure and performance" at work
Regarding this, many experts on the Internet suggest this, that is, open the editor first Converter, write out the structure completely, and then write the performance in CSS, and try not to touch the already written structure.
However, it is difficult for people who use reading books as their main learning method to understand, because most books about standards teach step by step, which means that they must combine structure and expression in a step-by-step manner. Although some books have suggestions in this regard, a few short sentences are far inferior to the subtle effects during the reading process. When the production staff can have a good grasp of the structure, writing structure and performance at the same time will not have much impact on the results. But in my experience, the working method of separating structure and presentation is much more efficient than writing structure and presentation at the same time. At the same time, it is not easy to miss elements on the page.
Of course, the so-called "separation of structure and performance" does not mean that performance is completely ignored. If you want to take performance into consideration, you must ensure that the CSS selector can select as much content as possible without destroying the structure. Where to add classes, or which labels to use to distinguish them, is a matter of opinion. I believe everyone has their own experience. Combining different design drafts, sometimes it is necessary to make corresponding changes. However, these changes should have the same premise - not destroying the structure and readability of the code.
Furthermore, you must realize that any visual tool is a devil. The effects presented in their visual interfaces are often thousands of miles away from those of real browsers. What we really want to be compatible with is the browser, not the visual interface of the editor.
5. CSS is not omnipotent, and it is not impossible to do without CSS
Compared to the CSS1.0 era, CSS can accomplish more things today, but demand is always ahead of technology, and CSS cannot accomplish it. For all the presentation layer work of web pages, sometimes we must combine JS or other languages to achieve some effects. Other times, using JS is much simpler than relying on CSS alone, and the code structure is better? The most typical example is the drop-down menu. At these times, we have to convince ourselves, or our bosses and customers, to use simpler and more reasonable methods. Because DOM is also an important component of web page standards, it does not mean that using JS will make our web pages less efficient or no longer standard. On the contrary, this is the biggest misunderstanding of JS. Having said this, I have to mention that in today's era, every profession is required to know more relevant knowledge than ever before. Those who do design must know a little bit about interaction and production, and those who do production must also understand design and programming, especially With front-end technologies like JS, only in this way can you and your colleagues work better together, and your personal development prospects will be brighter.
No CSS means that when our website fails to load the CSS file due to various unknown reasons, don’t panic because of this. This is the best time to test the quality of our code. If the web page still maintains good readability without CSS, this achievement is far more worthy of our pride than passing W3C verification.