首页 > 其他分享 >COMP3322 notes P2 - HTML Basic

COMP3322 notes P2 - HTML Basic

时间:2023-09-22 12:13:17浏览次数:45  
标签:P2 ... elements semantic notes content HTML Basic page

用课程上介绍的 HTML validation 网站 W3C Markup Validator 检查了一下本站 HTML 文件的正确性,结果弹出了 57 个 Error 与 Warning。我在魔改的时候到底做了些什么啊……

不过从这也能看出 HTML 语言的 permissive 性质;宽松的语法与 browser 也是 Web 长盛不衰的原因之一。


{% note warning %}

  This article is a self-administered course note.

  It will NOT cover ny exam or assignment related content.

{% endnote %}


HTML Basic

HTML is a type of markup languages. It annotates a document in a way that

  • annotations distinct from the text being annotated.
  • annotations indicate information about the content (through tags a.k.a., elements).

Keywords. [见 slides 02-HTML]

  • New insight (CSS 应承担提供信息的责任而 HTML 则专注于文档的 structure).
  • HTML history.

HTML Structure

一个 HTML document 的基本结构如下:

  • Web content.
  • HTML elements specified by a pair of tags. (元素;标签)
    • Opening tag.
      • Attributes : name=value pair.
    • Closing tag (omittable in void element)

Keywords. [见 slides 02-HTML]

  • elements and attributes.
  • nesting HTML elements.
  • basic document structure.
    • <!DOCTYPE .. > (not a element)
    • <html>: root element.
    • <head>: contains <title>, <link> (external CSS), <style> (internal style), <script> (JavaScript), <base>, <meta> (metadata).
    • <body>: contains elements that will be displayed in the browser.

HTML Elements

Keywords. [见 slides 02-HTML]

  • HTML comment <!-- -->.
  • block-level elements v.s. inline elements.
  • semantic elements: clearly describe ite meaning to the browser and the developer.
  • headings. <h1>, ..., <h6>. (block-level & semantic)
  • paragraphs. <p> (inline & semantic)
  • divisions. <div> (block-level) - contemporary web design, divs within divs with divs.
  • spans. <span> (inline) - inline version of divs.
  • links. <a> - href=[destination] attribute.
  • images. <img> - only content image.
  • lists. - unordered <ul>, ordered <ol>, and description <dl> (e.g., FAQ) - <li>.
  • tables. <table> - rows <tr> - headings <th> - cells <td>.
  • forms. <form> - collect info from visitors - two attributes:
    • action=. URL of the server-side resource that will process the submitted form.
    • method="get" or method="post". GET v.s. POST.
  • input controls (inside <form>) - <input type="text" ...>, <textarea ...>...

HTML Validation

HTML itself doesn't suffer from syntax errors because browsers parse it permissively.

  • The browser still displays the page even if there are syntax errors.
  • The browser has built-in rules to interpret incorrectly written markup.

Use HTML validation service to check the HTML code.


HTML5 Semantic Elements

HTML5 中引入了许多新的 semantic elements。

semantic elements describe both the structure and meaning of the page (content).

  • It is reader-friendly.
  • The semantic structural elements make it easier for users to navigate the page using assistive technology for accessibility.
  • A great deal of web content can be made accessible just by making sure the correct HTML elements (elements with the correct meaning) are used for the correct purpose at all times.

Keywords. [见 slides 02-HTML]

  • <header>. site logo, title, horizontal navigation links... (page header or <article> header)
  • <footer>. smaller navigation, copyright notices... (page footer or <article> footer)
  • <main>. specify the main content of a document, which should be unique to that page.
  • <nav>. specify major navigation blocks.
  • <article>. represent a section of semantically related content.
  • <section>. represent a generic section of content with the same theme. 理解为 chapter。
    • section v.s. div: if the contents are listed explicitly in document's outline, use <section>.
  • <figure> and <figcaption>. should not be used to wrap every image.
  • <aside>. contain content that is not part of the flow of the text. e.g., sidebar, call-out boxes...
  • <details> and <summary>. create an interactive widget.
  • <time>. define a human-readable date/time.
  • <mark>. highlight text.

Reference

{% note warning %}

  This article is a self-administered course note.

  References in the article are from corresponding course materials if not specified.

{% endnote %}

Reference website:

Introduction to HTML - mdn web docs.

Course info:

Code: COMP3322, Lecturer: Dr.Anthony Tam.

标签:P2,...,elements,semantic,notes,content,HTML,Basic,page
From: https://www.cnblogs.com/VeniVidiVici/p/17722002.html

相关文章

  • P1075 [NOIP2012 普及组] 质因数分解
    算法一根据唯一分解定理,小于\(n\)的最大的能整除\(n\)的整数一定就是答案,可以暴力枚举。时间复杂度\(O(n)\),实际得分\(60\)。算法二发现算法一不能通过的原因是较大的那个质数可能的取值范围太大了。而较小的那个质数一定小于等于\(\sqrtn\),我们枚举它即可。时间复......
  • [NOIP2012 普及组] 摆花
    [NOIP2012普及组]摆花[NOIP2012普及组]摆花题意有\(n\)个数,每种可以选\(0\lex_i\lea_i\)个,问有多少种方法可以使得\(\sum_{i=1}^nx_i=m\)。Solution1.深搜\(dfs\)显然可以先暴力深搜。#include"bits/stdc++.h"usingnamespacestd;constintmaxn=......
  • P1024 [NOIP2001 提高组] 一元三次方程求解
    因为精度要求很低,所以有一个暴力的想法就是枚举区间内相差很小的两个数然后判断。保留两位小数后记得判重。考虑优化。发现根与根差的绝对值大于等于\(1\)这个条件没有利用。有了这个条件我们发现相邻两个整数之间(不包含端点)最多有一个根。于是可以先判掉整数然后在区间内有根......
  • Parallel Programming Basic
    Learnaboutthedifferencebetweentime-efficiency(moreimportant)andwork-efficiencyparallelloopRelativeinstructionsetSSE(StreamingSIMDExtensions)instructionsetAVX(AdvancedVectorExtensions)instructionsetItisx86microprocessorinstruc......
  • P1056 NOIP2008 普及组 排座椅
    \(P1056\)[\(NOIP2008\)普及组]排座椅题解先想一下算法:因为题目里出现了最优解,最好的方案关键字,所以一定会用贪心。然后从题目给的样例解释可以看到:如果相邻的两行有许多组说话的同学,那么在这两行中间加一条过道是非常划算的;同理,列也是如此。恍然大悟,只要找出划分哪些......
  • 推荐收藏!年度Top20开源许可证风险等级
    开源许可现状开发人员经常在软件中引入开源的代码片段、函数、方法和操作代码。因此,软件代码中经常会包含各种声明不同许可证的子组件。这些子组件的许可证条款和条件与项目整体主许可证的条款和条件冲突时,就会产生许可证合规风险。Synopsys2023OpenSourceSecurityandRisk......
  • P2P协议的传输艺术
    FTP采用两个TCP连接来传输一个文件。控制连接:服务器以被动的方式,打开众所周知用于FTP的端口21,客户端则主动发起连接。该连接将命令从客户端传给服务器,并传回服务器的应答。常用的命令有:list——获取文件目录;reter——取一个文件;store——存一个文件。数据连接:每当一个文件在......
  • P2501 [HAOI2006] 数字序列
    先来看第一问。发现直接做要考虑两数中间的数能否变得合法,所以按套路将\(a_i\)减去\(i\),这样就只要变成单调不降,只要两数合法中间的数就一定能变得合法。考虑不改变的那些数,它们一定单调不降,所以答案就是序列总长度减去最长不下降子序列的长度。接下来看第二问,尝试观察一些性......
  • P2679 [NOIP2015 提高组] 子串
    注意\(A\)中取相同位置子串划分方式不同也算作不同的方案。令\(f_{i,j,l,0/1}\)表示\(A\)中前\(i\)个字符,取出\(l\)个子串,拼成了\(B\)中前\(j\)个字符,第\(i\)个字符取/不取的方案数。不取直接累加\(A\)中上一个字符的状态:\[f_{i,j,l,0}=f_{i-1,j,l,0}+f_{i-1......
  • P2759 奇怪的函数
    不学不知道,做过初升高暑假作业就会了。\[\largex=10^{\log_{10}^x}\]\[\largex^x=\left(10^{\log_{10}^x}\right)^x=10^{x\log_{10}^x}\]因为是达到或超过,所以指数下取整加一即是位数。然而\(x\)的范围比较大,直接枚举不行,要二分。......