0

我想在我的 HTML 源代码中显示评论,但仅在源代码中而不是在页面的实际呈现内容上。例如,当用户右键单击他们的浏览器窗口并选择“查看源代码”时,我希望评论可见以供他们阅读,但我不希望评论在实际呈现的网站上可见。

我试过

<span style="visibility: hidden;">
    Joe Hancock - 04/16/12 - Some comment
</span>

但是这样做会占用网页上的实际空间(空白),并且真的会影响我的风格。

有人知道这样做的好方法吗?

4

3 回答 3

7
<!--This is a comment. Comments are not displayed in the browser-->

HTML 注释

于 2012-04-16T18:06:36.980 回答
2

试试这个:

<!-- Comment goes inside here -->
于 2012-04-16T18:08:34.837 回答
0
1<div style="display:none">This is hidden</div>2
于 2012-04-16T18:07:38.060 回答