CSS :link and :visited pseudo-classes - are web browsers adhering to the spec?

﹥>﹥吖頭↗ 提交于 2019-12-04 03:22:56

The line,

"UAs may therefore treat all links as unvisited links, or implement other measures to preserve the user's privacy while rendering visited and unvisited links differently."

Isn't applicable to styles returned by JavaScript only — it is exactly as it sounds. This means that browsers may just ignore certain properties on :visited entirely (which is what's happening in this case). Since the font-size would increase the size of the containing element, allowing the property to be different for :visited links would undermine the other security measures implemented by the browser.

A browser could choose to recalculate the dimensions without the :visited styles applied, if it wanted to. Naturally, this is more work and less performant than just disallowing certain properties. It's clear that the decision has been made based on the fact that there is no real need to use different font sizes, backgrounds, etc to differentiate between visited and unvisited links and, generally, most developers will stick to just modifying the colour slightly.

So no, they're not deviating from the spec, they're taking advantage of a permissible exception.

From what I understand from the spec, the browsers are treating :link like a to avoid the abuse on the visited status. Therefore with or without javascript, the style actually applied to all the links is :link, and the :visited only is overloading the style when visited.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!