You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
style is supposed to be included only on the head of the document.
Besides the validation point, one caveat that might interest you when using style on the body is the flash of unstyled content. The browser would get elements that would be styled after they are displayed, making them shift on size/shape/font and/or flicker. It is generally a sign of bad craftsmanship. Generally you can get away with putting style anywhere you want, but try to avoid it whenever it is possible.
style 标签应该只放置在文档的 head 标签中
除了验证相关的点外,当你在 body 中使用 style 标签会使得未样式化的内容出现闪烁,这样的警示也许会引起你的注意。浏览器会把这些已经展示出来的元素再结合相应的样式渲染,使得它们可能会在大小、形状、字体这些方面切换或者闪烁。通常这并不是一个很好的做法。然而你可以把你的 style 标签放置在任何你想要的地方,但并不推崇这样的做法。
The text was updated successfully, but these errors were encountered:
前阵子面试遇到一个面试题是就是问这个,当时没答好,当时我的回答是,为了初始化(reset)标签样式之类的 ,当时就感觉到并不是面试官想要的,回来找了好一阵子都没有翻到想要的答案,后来上 Stackoverflow 才找到像样的答案
Does <STYLE> have to be in the of an HTML document?
其中最高赞回答中说了,稍微简单的翻译了一下,意思大致就是这样
The text was updated successfully, but these errors were encountered: