首页 > 解决方案 > 如何将样式应用于 HTML element?</h1> <div id="body"><p>My question is simple, I just want to know that is there any way to apply CSS style to HTML element. Like the following declaration:</p> <pre><code>title{ col</p> </div> <div class="container" id="article"> <div class="page-header"> <h1>html - 如何将样式应用于 HTML<title> element?</h1> <div id="body"><p>My question is simple, I just want to know that is there any way to apply CSS style to HTML element. Like the following declaration:</p> <pre><code>title{ col</h1> </div> <div class="con"> <h3>问题描述</h3> <p class="author">标签: <span>html</span><span>css</span><span>title</span></div> <h3>解决方案</h3> <hr> <div class="con "> <div class="body"> <p>不,没有办法为这个元素设置样式,因为它是由浏览器和用户控制的。在查看页面时,您唯一可以对标题做的事情就是更改它,但保持在同一页面上:</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function changeTitle() { document.title = "Title Changed!"; document.getElementById('test').innerHTML = "Title has been changed!"; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><button onclick="changeTitle()">Click Me!</button> <p id="test"></p> <p>View source to see the effect!</p></code></pre> </div> </div> <p></p> <p>抱歉缺少<code><title></code>样式,但就是这样。也许在 CSS4 中,他们可能会改变它。但是,我对此表示怀疑。</p> </div> <div class="clear"></div> </div> <hr> <h3>推荐阅读</h3> <ul> <li><a href="/question/56343769.html">python - 这可能吗:将虚拟环境克隆到每个用户的笔记本电脑,而源代码和相关文件保留在网络驱动器中</a></li><li><a href="/question/56343774.html">c++ - 如何在 winApi 上正确创建按钮并处理其消息</a></li><li><a href="/question/56343783.html">python - 如何在 kivy 中的形状之间添加填充?</a></li><li><a href="/question/56343787.html">android-10.0 - Android Q Edge to Edge 应用内容不显示透明导航栏</a></li><li><a href="/question/56343789.html">java - restTemplate.getForObject 上的 HttpClientErrorException</a></li><li><a href="/question/56343790.html">c# - 如何在 C# 中压缩我的世界块?</a></li><li><a href="/question/56343801.html">oracle - 带有Oracle的PHP PDO,当输出参数是游标时调用存储过程</a></li><li><a href="/question/56343803.html">php - Laravel:不允许序列化 'Illuminate\Http\UploadedFile'</a></li><li><a href="/question/56343805.html">django - DatabaseError:无法在 django 上打开数据库文件</a></li><li><a href="/question/56343811.html">cypress - 如何在测试运行之前存根在 html 上定义的变量</a></li> </ul> </div> <footer> <p><a href="/">时间戳在线转换</a></p> </footer> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6117966252207595" crossorigin="anonymous"></script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?7145e10314e5e27e886ad54be2aeb067"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body></html>