HTML DOM Style quotes 属性

htmlweb developmentfront end technology更新于 2025/6/11 4:28:17

HTML DOM Style quotes 属性返回并修改 HTML 文档中用于括住引号的引号类型。

语法

以下是语法 −

  • 返回引号

object.style.quotes
  • 修改引号

object.style.quotes = “value”

值

此处,值可以为 -

值说明
inherit从其父元素继承此属性值。
initial将此属性值设置为其默认值。
none设置用于引用的默认引号(“”)。
string string
string string
设置引号。其中前两个值指定第一级引号,后两个值指定下一级引号。

示例

让我们看一个 HTML DOM Style quotes 属性的示例 −

<!DOCTYPE html>
<html>
<head>
<style>
   body {
      color: #000;
      background: lightblue;
      height: 100vh;
   }
   q {
      margin: 20px;
   }
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
      margin: 20px;
   }
</style>
</head>
<body>
<h1>DOM Style quotes Property Example</h1>
<q>I'm a q element with some dummy text.</q>
<button onclick="add()" class="btn">Change quotes</button>
<script>
   function add() {
      document.querySelector('q').style.quotes = "'#' '#'";
   }
</script>
</body>
</html>

输出

这将产生以下输出 −

点击“更改引号”按钮来更改引号。


相关文章


有用资源