Notes
  • Notes
  • JavaScript
    • URL processing
    • Numbers
  • Python
    • python random notes
    • Python Resources
  • Setup
    • Mac Setup
  • Command Line
    • Basics
    • Linux basics
    • Bash script
    • Create temp files
    • awk
    • sed
    • make
    • ssh
    • gzip
    • Command line tools
    • ffmpeg
    • at and crontab - scheduling commands
  • Web Developement
    • Chrome Dev Tools
    • HTML
    • Markdown
    • CSS
    • Rails
    • Hugo
    • REST APIs
  • Soft Skills
    • Listening Skills
    • Public Speaking
  • Containers
  • Career
    • Resume
    • Interview
    • Promotion
    • Keeping Track of Your Work
    • Decide What to Work On
  • Ergonomics
    • Work Env Setup
    • Pain Relieve
  • Digest / Writing Ideas
    • Books
      • Antifragile
      • Anti-Intellectualism in American Life 美国的反智传统
    • Economy / Society
    • How to spend your time
    • Life
    • Higher education
  • Misc
    • Regex
    • Don't Make Me Think
    • Microsoft Excel
    • AdTech 101
  • Resources
    • web
    • Vim
    • Tools
    • System Design
    • Design Pattern
    • Load Balancer
    • References
    • Hardware
    • Algorithm Resources
    • Command Line Resources
  • Git
    • Pro Git
  • Non-Tech
    • 化学科普 - 拿破仑的纽扣
    • 人生经验 - If I Knew Then
    • 哲学
      • Harvard - Justice
    • 宗教
      • Introduction to the New Testament History and Literature
      • 蔡志忠 - 漫画东方圣经
    • 人文
      • Open Yale Course - 心理学导论
  • Spark
  • VS Code
Powered by GitBook
On this page
  • Ref
  • HTML Intro
  • <meta>
  • URL Intro
  • Attributes
  • HTML character encoding
  • HTML tags
  • Text tags
  • Table tags
  • Image
  • Link
  • Other tags

Was this helpful?

  1. Web Developement

HTML

PreviousChrome Dev ToolsNextMarkdown

Last updated 4 years ago

Was this helpful?

Ref

HTML Intro

  • block elements: take a whole line.

  • inline elements: no new line.

Tags are case insensitive. <img> is the same as <IMG>.

Attributes are case insensitive. onclick is the same as onClick. Usually values are in double quotes.

HTML ignores indentation and newlines.

<title>My Blog</title>

is the same as

<title>
    My Blog
</title>

<!-- 这是一个注释 -->
<!--
  <p>hello world</p>
-->

Browser combines multiple whitespaces, \t, \n, \r.

<p>hello      world</p>
is the same as
<p>hello world</p>

<meta>

<meta charset="utf-8">
<meta name="key" content="value">

URL Intro

18 characters are reserved: they can only appear at certain places in URL. If those characters are used elsewhere in URL, they need to be escaped (% + ASCII code). Encoding other characters are not recommended.

  • space:%20

  • !:%21

  • #:%23

  • $:%24

  • &:%26

  • ':%27

  • (:%28

  • ):%29

  • *:%2A

  • +:%2B

  • ,:%2C

  • /:%2F

  • ::%3A

  • ;:%3B

  • =:%3D

  • ?:%3F

  • @:%40

  • [:%5B

  • ]:%5D

Other characters (not reserved, not legal) will be encoded to UTF-8 by browser (汉字).

Attributes

<p id="p1" class="big bright"></p>
<div title="版权说明">
  <p>本站内容使用创意共享许可证,可以自由使用。</p>
</div>
title will be shown as a tooltip when hovered.

data- attributes can be used by CSS or JavaScript. CSS example:

/* HTML 代码如下
<div data-role="mobile">
Mobile only content
</div>
*/
div[data-role="mobile"] {
  display:none;
}

/* HTML 代码如下
<div class="test" data-content="This is the div content">test</div>​
*/
.test {
  display: inline-block;
}
.test:after {
  content: attr(data-content);
}

event handler: values are JavaScript code. Keys:

onabort, onautocomplete, onautocompleteerror, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, onclose, oncontextmenu, oncuechange, ondblclick, ondrag, ondragend, ondragenter, ondragexit, ondragleave, ondragover, ondragstart, ondrop, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onsort, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting

HTML character encoding

<p>hello</p>
<!-- 等同于 -->
<p>&#104;&#101;&#108;&#108;&#111;</p>
<!-- 等同于 -->
<p>&#x68;&#x65;&#x6c;&#x6c;&#x6f;</p>

entity: &name;

  • <:&lt;

  • >:&gt;

  • ":&quot;

  • ':&apos;

  • &:&amp;

  • ©:&copy;

  • #:&num;

  • §:&sect;

  • ¥:&yen;

  • $:&dollar;

  • £:&pound;

  • ¢:&cent;

  • %:&percnt;

  • *:$ast;

  • @:&commat;

  • ^:&Hat;

  • ±:&plusmn;

  • 空格:&nbsp;

HTML tags

  • <header>

  • <footer>

  • <main>

  • <article>

  • <aside>

  • <section>

  • <nav>

  • <h1> ~ <h6>

  • <hgroup>

Text tags

  • <br>: for inline elements

<pre>hello

   world</pre>

preformatted, keeps spaces and newline
multiline <code> has to be in <pre>
<pre>
<code>
  let a = 1;
  console.log(a);
</code>
</pre>
  • <strong> <b>

  • <em> <i> (emphasize)

  • <sub> <sup> <var> (variable in math formula)

  • <u> underline <s> strikethrough

  • <blockquote> <cite> <q>

  • <ins>标签是一个行内元素,表示原始文档添加(insert)的内容。<del>与之类似,表示删除(delete)的内容。它们通常用于展示文档的删改。

  • <small>: no need for CSS.

  • <mark>: for highlight.

Table tags

  • <ol>: attributes: reversed, start="5", type

    • type属性指定数字编号的样式。目前,浏览器支持以下样式。

      • a:小写字母

      • A:大写字母

      • i:小写罗马数字

      • I:大写罗马数字

      • 1:整数(默认值)

<ol type="a" start="3">
  <li>列表项 A</li>
  <li>列表项 B</li>
  <li>列表项 C</li>
</ol>
  • <li>: value

<ol>
  <li>列表项 A</li>
  <li value="4">列表项 B</li>
  <li>列表项 C</li>
</ol>

Image

Link

  • <a> can have mailto: as href.

  • <link>: rel="stylesheet" relation

Other tags

  • New tags

    • <dialog>: native modal

    • <details> <summary>

<ruby> for pinyin

responsive image

tables

Forms

https://wangdoc.com/html/text.html#ruby
https://wangdoc.com/html/image.html
https://wangdoc.com/html/table.html
https://wangdoc.com/html/form.html
encodeURIComponent() - JavaScript | MDN
HTML 教程
Logo
Logo