我想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"><p xlink:xref …Run Code Online (Sandbox Code Playgroud)