小编Dua*_*Yao的帖子

CSS 命名空间属性选择器可以与 XHTML/HTML 元素一起使用吗?

我想xlink:href在 XHTML 中使用属性设置元素的样式,但是我无法使其工作。我的测试代码:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xyz="http://xyz.org">
<head>
<meta charset="UTF-8" />
<title>css namespace</title>
<style>
body { font-size: 20px; } /* Oops! A normal rule must not precede @namespace rules! */
@namespace html "http://www.w3.org/1999/xhtml";
@namespace xlink "http://www.w3.org/1999/xlink";
@namespace xyz "http://xyz.org";
html|p {
  color: blue;
}
[xlink|href], [xyz|href] {
  cursor: pointer;
  text-decoration: underline;
  color: red;
}
xyz|p, xyz {
  display: block;
}
</style>
</head>
<body>
<!-- typos: 'xref' should be 'href', thank BoltClock's answer! -->
<p xlink:xref="aaa">&lt;p xlink:xref …
Run Code Online (Sandbox Code Playgroud)

html css xhtml xml-namespaces css-selectors

7
推荐指数
1
解决办法
3368
查看次数

标签 统计

css ×1

css-selectors ×1

html ×1

xhtml ×1

xml-namespaces ×1