This article is recorded in bytedance youth training camp Teacher Ma Chao told the basic HTML course observation.
Three Elements of the Web
The basic webpage is composed of three front – end sets
- HTML: The basic structure of a web page
- CSS: The presentation of a web page
- JS: The function and behavior of web pages
For humans, HTML is the skeleton, CSS is the skin, and JS is the behavior
Introduction of HTML
HTML, short for Hypertext Markup Language, is a Markup Language based on SGML (Standard General Markup Language), and is the Web’s primary tool for editing Web pages. Online publishing and distribution on a global scale requires a widely understood language, a “mother tongue” for publishing that all computers can understand. The publishing language of the World Wide Web (WWW) was HTML.
The development history
-
An Internet-based hypertext system proposed by Berners-Lee in 1989.
-
The first version of HTML was born in 1993 when the IETF published the first HTML proposal
-
1995 HTML2.0 release, including form-based file upload, tables, internationalization and other functions
-
The W3C was formed in 1994 to take over HTML standardization and released HTML3.2 in 1997
-
HTML4.0 uses many browser-specific element types and attributes
-
HTML5 was released as a W3C recommendation in 2014
HTML structure
-
An HTML document contains multiple HTML elements with different characteristics
-
HTML element = start tag + end tag + element content
-
Some elements have only one tag, such as IMG, input, br, and so on
-
HTML element tags are case insensitive
-
Elements can be nested among other elements
-
Elements can have attributes that contain additional information about the element
<! < HTML >: the root element, which contains the entire content of the page <head>: is not visible to the user. <body>: This element contains content that can be accessed by the user, including text, images, video, games, audio, and so onCopy the code
HTML Page structure
Detail of the elements in head
meta
There are four attributes in the meta: charset/name/http-equiv/content
charset | name | http-equiv | content |
---|---|---|---|
Specifies the character encoding of the current document | Associate the Content attribute to the HTTP header | Associate the content attribute with a name | containshttp-equiv orname The value of the attribute |
<meta name="keywords" content="HTML"> <meta name="description" Content ="HTML base "> <meta name="viewport" content="width= device-width, initial-scale =1.0, maximum-scale =1.0, User - scalable = 0 "> HTTP headers custom meta, used to provide some information to a particular site https://wiki.whatwg.org/wiki/MetaExtensions < meta" HTTP - equiv = "expires" content="31 Dec 2021">Copy the code
title
The HTML
base
The HTML element specifies the root URL to be used for all relative urls contained in a document. There can only be one element in a serving.
link
The HTML external resource Link element ( ) specifies the current document’s relationship to the external resource. This element is most commonly used to link stylesheets, but can also be used to create site ICONS (such as the “Favicon” icon on PC and the icon to display on the home screen on mobile devices).
Href ="favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="my-" <link href-"fancy. CSS "rel="alternate styleshet" type="text/ CSS" title=" fancy ">Copy the code
script
<script type="text/javascript" SRC =" javascret.js ">Copy the code
Script has two attributes
-
Defer: instantly download, delay the, said script can wait until the dom after being parsed and displayed in full in the execution, applies only to external script. The script with the defer property blocks the DOMContentL oaded event until the script is loaded and parsed.
-
Async: downloads scripts immediately and does not interfere with other operations, such as downloading other resources or loading other scripts. It is valid only for external scripts
style
HTML elements contain style information for a document or portions of the document. By default, the style information for this tag is usuallyCSSThe format.
Common elements
Elements in body
Inline element
-
Occupies only the space contained by the border of its corresponding label
-
Can only hold text or other inline elements
-
Dimensions can only be changed by modifying horizontal margins, borders, or row heights
-
The commonly used inline elements: < a >, < span >. < br >, < I >, < em >, < strong >, < label >, < q >. < var >, < cite >, < code >
Block-level elements
-
The entire row that occupies its parent element always starts on a new row
-
Can hold other block elements or inline elements
-
You can control width height, line height, margin, border and so on to change its size
-
Common block-level elements
,,
–
,
-
,
-
,
-
,
,
,
,
Inline block-level elements
- Elements are arranged within a row and do not own a row
- You can set the width, height, vertical margin, and border
- Common inline elements:
<img> <input> <td>
semantic
Depending on the structure of the content, choosing the right tags builds a more maintainable code structure that developers can read and that machines can parse better.
For example, use button instead of div to define a button
block
header
- Present introductory information
- Usually contains a set of introductory or navigational elements such as a title, Logo, search box, author name, etc
- Can be placed inside, or another element
nav
- Provide navigation links in the current document or other documents, such as menus, directories, indexes, and so on
- This is used to place the most popular links. The less common links are usually placed in the footer at the bottom
article
- Separate documents, pages, applications, sites
- Independently assignable or reusable structures, such as forum posts, news articles, blogs, user-submitted comments, interactive components, etc
section
- Group content by topic, usually with a title
- It usually appears in the outline of a document
- Do not use it as a normal container, for example to beautify fragment styles
A more appropriate
- If there are separate chunks of content inside the element that can be published individually, it is more suitable
aside
- Represents a section that has little to do with the rest of the page’s content, or that does not affect the overall content when taken apart
- Usually used in the sidebar to display ads, tips, quotes, etc
footer
- Represents the footer of the most recent chapter
- Usually contains information about the author of the chapter, copyright data, or a link to the document
- Elements within the footer are not part of the section and are not included in the outline
grouping
figure figcaption
<figure>
The contents of the package that are referenced independently: charts, illustrations, code, etc., usually with a title<figcaption>
The description/title of the chart associated with it, usually located at<figure>
The first or last of
blockquote
- Block-level reference elements
- The cite attribute represents the URL of the source
dl ,dt ,dd
- Used to describe – group key – value pairs
- Usually used in metadata, term definition, and other scenarios
The text
cite
- The element is usually used to refer to the title of the work.
- Include citations of papers, documents, books, movies, etc
time
- Machine readable time and date
- Datetime indicates the date and time to which this element is associated. If not specified, the element will not be resolved to a date
<address>
Contact information for a person or organization<mark>
Used in references to indicate that attention is required<code>
Code snippet<small>
Disclaimer, notes, etc
Multimedia elements
The picture
img
- The SRC attribute is required to embed the image in the file path
- The Alt attribute contains a text description of the image and is optional. The screen reader will then read these descriptions to the user who wants to use the screen reader to let them know what the image means. When the image fails to load (network error, content blocked, or link expired), the browser displays the text in the Alt attribute on the page
- Decoding modes: asynchronous and synchronous
- Loading a lazy loading
picture
- Elements by containing zero or more elements and aElement to provide versions of images for different display/device scenarios
- Media properties: render the corresponding image according to the media conditions, similar to media query
- The TYPE attribute: the MIME type that renders the corresponding image according to what the browser supports
Audio and video
video
- The SRC attribute is required to embed the video file path
- Controls Specifies whether to display browser controls. You can create custom controls
- Autoplay Indicates whether toplay autoplay
- The source element represents alternative resources for the video (different formats, sharpness, and sequence of attempts if reading fails or decoding fails)
HTML parsing
The general steps are as follows
- Build a DOM tree
- Style calculation to build the CSSOM tree
- Combine DOM and CSSOM into a Render tree
- Layout calculation
- draw
DOM(Document Object Model) : A structured representation of nodes and defines a way for programs to access this structure linking Web pages to scripting languages