


Foreword
In the past two weeks, I have participated in the company's new project, using closed development (project members develop in the conference room), working overtime until late at night , so I don’t have the time and energy to write an original blog. Today I will share my reading notes on "Writing High-Quality Code - How to Practice Web Front-End Development".
Text
If you want to master one line, you must first understand ten lines.
In the field of front-end development, it is very necessary to have one specialty and multiple abilities.
Table layout disadvantages:
css layout: div css, or (x)html css.
Small amount of code, streamlined structure, and fresh semantics.
The less code, the browser download time will be shorter;
The clear semantics will be more friendly to search engines.
First determine the html, determine the semantic tags, and then choose the appropriate CSS.
The browser will give a default style based on the semantics of the tag.
A simple way to judge whether the semantics of web page tags is good is to remove the style and see whether the web page structure is well organized and orderly, and whether it is still readable.
Test whether the CSS settings in the web page are disabled in DevTool? Test the effect of w3c official website after removing the style.
When the tags on the page cannot meet the design needs, non-semantic tags such as div and span will be appropriately added to assist the implementation.
The table layout is suitable for displaying two-dimensional data.
Some other issues that should be paid attention to with semantic tags:
There is no perfect solution to the problem of too scattered and concentrated files. We need to make appropriate compromises based on the actual situation.
css rest:
Supplement:
Reset browser default style, recommended: https://github.com/necolas/normalize.css
Split modules:
Camel case is used to distinguish words, and underlining is used to indicate affiliation. For example: .timeList-lastItem.
Learn this style of naming:
.fr { float: right; }
.w25 { width: 25%; }
Use composition more and inheritance less.
When there is a conflict between style settings, the style with higher weight will be used.
The weight of html tag: 1, the weight of class: 10, the weight of ID: 100.
When the weights are the same, the nearest definition principle will be used.
In order to ensure that the style can be easily overridden and improve maintainability, the weight of the CSS selector should be as low as possible.
CSS hack methods are usually selector prefix method and style attribute prefix method.
Block-level elements and inline elements:
hasLayout:
is a proprietary attribute designed by IE browser to parse the box model. It was originally designed to be used for blocks. For level elements, if hasLayout of inline elements is triggered, the inline elements will have some characteristics of block-level elements.
display: inline-block
An inline block-level element, which has the characteristics of block-level elements: you can set the width, height, margin and The padding value also has the characteristics of inline elements: it does not occupy an exclusive line.
will trigger hasLayout. Vertical alignment can be solved by setting *vertical-align: -10px.
In order to make E6, IE7 and other browsers compatible with display: inline-block, there are also certain problems:
Although IE6 and IE7 do not support CSS setting to display: inline-block, in fact the CSS parsing engines of IE6 and IE7 still have display: inline-block. For example, both img tags and button tags have display : Inline-block feature, you can set the width and height without occupying an exclusive line.
float
will change the normal document flow arrangement and affect surrounding elements.
position: absolute and float: left or float: right will implicitly change the display type. No matter what type of element it was before (except display: none), the element will be displayed in display: inline-block mode. : You can set the width and height. The default width does not occupy the parent element.
Centered
(1) Horizontal centering of inline elements such as text and pictures: set text-align to the parent element : center
(2) Horizontal centering of block-level elements with determined width: Set margin-left: auto and margin-right: auto
(3) Horizontal centering of block-level elements with uncertain width:
I. Use the table package and set margin: 0 auto; Advantages: Clever approach. Disadvantages: Added unsemantic tags and deepened the nesting levels of tags.
II. Use display: inline/inline-block; Advantages: Simple and clear, clear structure. Disadvantages: After using inline, it becomes an inline element and lacks certain features, such as: width, hieght...
III. Use position: relative, set float, position: relative and left: 50% for the parent element, and set float, position: relative and left: 50% for the child element. Set position:relative and left:-50%. Advantages: Clear structure. Disadvantages: position:relative will bring some side effects.
(1) Vertical centering of text, pictures, and block-level elements whose parent element height is uncertain: Set the same top and bottom padding to the parent container to achieve this.
(2) Vertical centering of a single line of text determined by the height of the parent element: line-height: height of the parent element.
(3) Vertically center multi-line text, pictures, and block-level elements whose parent element height is determined:
I. Using table wrapping, disadvantages: adding unsemantic tags and increasing the number of nesting levels.
II. For IE8 and Firefox that support display: table-cell, use display: table-cell and vertical-align: middle to achieve centering. For IE6-7 that does not support it, use a specific format hack: give parent and child two layers The elements are set to { *position: absolute; *top: 50% } and { *position: relative; *top: -50% } to achieve centering. Disadvantages: Using it for hacking is not conducive to maintenance. Setting position: relative; position: absolute; brings some side effects.
Grid layout
No matter who is left or right in style between sidebar and main, in the html tag, make sure that the main tag is in the sidebar was loaded before.
Only the outermost container is given a specific width, the width of all other containers is set as a percentage ?? Grid layout.
z-index
The z-axis is activated after the element sets position to absolute or relative.
Setting negative margins can cause the positions of adjacent elements to overlap. Which one floats on top depends on the order in which the html tags appear. The tags that appear later float on top of the tags that appear first.
For the select occlusion problem under IE6, you can use an iframe of the same size to cover the select.
In order to avoid the overlap problem of the upper and lower margins of components and the bug caused by IE's hasLaout, all modules use margin-top to set the upper and lower margins, except for special needs.
Javascript

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools