$ ls ~yifei/notes/

html 的一些小知识和陷阱

Posted on:

Last modified:

如何自定义 favicon

<link rel="shortcut icon" type="image/png" href="/favicon.png"/>

html 中的空格

Multiple spaces in html is displayed as one, to show multiple space

  1. use <pre> around the word
  2. use &nbsp;

Image lazy-loading

<img src="image.jpg" loading="lazy" alt="Alternative Text" />

其他资源加载优先级可以用 importance

<img src="img/carousel-4.jpg" importance="low">
<script src="async_but_important.js" async importance="high"></script>

Force download

<a href="path/to/file" download> Download </a>

Use forms in table

<form method="GET" id="myform"></form>
<table>
  <tr>
    <td>
      <input type="text" name="username" form="myform" />
      <button form="myform">OK</button>
    </td>
  </tr>
</table>

显示所有边框

for (let e of document.getElementsByTagName('*')) {
    e.style.outline = '1px solid red'
}

References

  1. https://mp.weixin.qq.com/s/WOpoYeLfO0VpiIoxTA6HJg
WeChat Qr Code

© 2016-2022 Yifei Kong. Powered by ynotes

All contents are under the CC-BY-NC-SA license, if not otherwise specified.

Opinions expressed here are solely my own and do not express the views or opinions of my employer.

友情链接: MySQL 教程站