Table of Contents
Key summary about html
Block elements, inline elements, inline block elements
1.Inline element
2. Block element
3. Inline block elements
<p style="color:red">这里文字是红色。</p>
Copy after login
" >
<p style="color:red">这里文字是红色。</p>
Copy after login
<style type="text/css">span{color:red;}</style>
Copy after login
" >
<style type="text/css">span{color:red;}</style>
Copy after login
2. You can use the position attribute to place an element anywhere on the web page.
Difference:
Home Web Front-end HTML Tutorial Summary of several key points in html learning

Summary of several key points in html learning

Jul 19, 2018 am 11:39 AM
html

Key summary about html

Block elements, inline elements, inline block elements

  • HTML can classify elements into There are three types of inline elements, block elements and inline block elements

  • Using the display attribute, the three can be converted arbitrarily

  • Block elements automatically Line break

  • Conversion method
    (1)display:inline;Convert to inline element
    (2)display:block;Convert to block element
    (3)display:inline-block;Convert to inline block element

  • Compare

1.Inline element

The most commonly used inline element is span, and the others are only used under specific functions, modifying the font <b> and <i> tags, and There are two tags, <sub> and <sup>, which can directly create a square effect without the help of similar movement attributes, which is very practical.

Characteristics of inline elements: (1) Setting width and height is invalid

      (2) Setting margin is only effective in left and right directions, not up and down; padding setting is effective in both up, down, left and right directions, which will expand the space

                              

<!DOCTYPE html>
  <html>

      <head>
          <meta charset="utf-8" />
          <title>行内元素</title>
          <style type="text/css">
              span {                  
              width: 120px;                 
              height: 120px;                 
              margin: 1000px 20px;                 
              padding: 50px 40px;                 
              background: lightblue;             
              }
         </style>
     </head>

     <body>
         <sspan>不会自动换行</span>
         <span>行内元素</span>
     </body>

 </html>
Copy after login
2. Block element

The representative block element is p, others such as p, nav, aside, header, Footer, section, article, ul-li, address, etc. can all be implemented using p. However, in order to facilitate programmers to interpret the code, specific semantic tags are generally used to make the code more readable and easy to check for errors.

Characteristics of block elements: (1) Able to recognize width and height

     (2) The top, bottom, left and right margins and padding are all valid for it

     (3) Can automatically wrap lines

                                                    graduate down through the arrangement by default

<!DOCTYPE html>
  <html>

      <head>
          <meta charset="utf-8" />
          <title>块状元素</title>
          <style type="text/css">
              p {                  
              width: 120px; 
               height: 120px;                 
               margin: 50px 50px;                 
               padding: 50px 40px;                 
               background: lightblue;            
                }
         </style>
     </head>

     <body>
         <i>自动换行</i>
         <p>块状元素</p>
         <p>块状元素</p>
     </body>

 </html>
Copy after login
3. Inline block elements

Comprehensive inline block elements It combines the characteristics of inline elements and block elements, but each has its own trade-offs. Therefore, inline block elements are used more often due to their characteristics in daily use.

Characteristics of inline block elements: (1) No automatic line wrapping

#

<!DOCTYPE html>
  <html>

      <head>
          <meta charset="utf-8" />
          <title>行内块状元素</title>
          <style type="text/css">
              p {                  
              display: inline-block;                 
              width: 100px;                 
              height: 50px;                 
              background: lightblue;             
              }
         </style>
     </head>

     <body>
         <p>行内块状元素</p>
         <p>行内块状元素</p>   
     </body>

 </html>
Copy after login

Absolute path and relative path

Absolute path: refers to the absolute location in the directory, directly reaching the target location, usually the path starting from the drive letter
  • Relative path: refers to the path relationship with other files (or folders) caused by the path where this file is located
  • Each one. Jump one level outward.
  • Three ways to write styles
1. Inline style:

Write the css code directly into the existing HTML tag
<p style="color:red">这里文字是红色。</p>
Copy after login
2. Embedded style:

Embedded css style means that you can write css style code between tags
<style type="text/css">span{color:red;}</style>
Copy after login
3. External style sheet:

External css style (also called external style) is to write the css code in a separate external file. This css style file has the extension ".css"
<link href="style.css" rel="stylesheet" type="text/css" />
Copy after login
Note:

css style file name must comply with the naming rules, such as main.css
  1. rel=”stylesheet” type=”text/css” is a fixed writing method that cannot be modified
  2. css files can also be introduced using import in
  3. , but this method cannot be operated with js

    Absolute positioning, relative positioning and fixed positioning
Note:

1. The position attribute can control how and where the web browser displays specific elements.
2. You can use the position attribute to place an element anywhere on the web page.
Optional values:

- static: Default value, the element does not have positioning enabled
– relative: Turn on relative positioning
– absolute: Turn on absolute positioning
- fixed: Turn on fixed positioning

3. Relative positioning

①Each element has a natural position in the document flow of the page. Moving an element relative to this position is called relative positioning. Surrounding elements are completely unaffected by this.

②When relative positioning is turned on, you can use the four attributes top, right, bottom, and left to position the element.

—-left: The left offset of the element relative to its positioning position. left: 100px, offset 100px to the right relative to the original position

—-right: the right offset of the element relative to its positioning position

—-top: the element relative to its positioning position The upper offset of the element

——-Bottom: The lower offset of the element relative to its positioning position

③Characteristics of relative positioning

——-If the element is not set Offset, the position of the element will not change.

——-Relative positioning is relative to the original position of the element in the document flow.

——-Relative positioning does not take the element out of the text flow. The element's position in the text flow does not change.

——-Relative positioning will not change the original characteristics of the element. Block element or block element, inline or inline

- Relative positioning will raise the level of the element so that the element can cover elements in the text flow.

4. Absolute positioning

①Absolute positioning means that the element is positioned relative to the html element or its nearest ancestor positioning element.

②When the position attribute is set to absolute, the absolute positioning of the element is turned on.

③When absolute positioning is turned on, you can use the four attributes top, right, bottom, and left to position the element.

④Characteristics of absolute positioning:

——Absolute positioning will completely separate the element from the text flow.

——-The width of an absolutely positioned block element will be stretched by its content.

——Absolute positioning will turn inline elements into block elements.

——-Absolute positioning is relative to the nearest ancestor element that has positioning turned on. If all ancestors do not have positioning turned on, they will be positioned relative to the browser window.

——Generally, when using absolute positioning, a relative positioning will be specified for its parent element to ensure that the element can be positioned relative to the parent element.

——-Absolute positioning will increase the level of the element.

5. Fixed positioning

①Fixed positioning elements will be locked at a certain position on the screen. When the visitor scrolls the web page, the fixed elements will remain stationary on the screen

②When the position attribute is set to fixed, the fixed positioning of the element is turned on.

③When fixed positioning is turned on, the four attributes of top, right, bottom, and left can be used to position the element.

④ Fixed positioning is also a kind of absolute positioning. Other characteristics of fixed positioning are similar to absolute positioning.

Difference:

(1) Fixed positioning is always relative to the browser positioning.

(2) will be fixed at a certain position in the browser window and will not scroll with the scroll bar.

(3)IE6 does not support fixed positioning.

The above is the detailed content of Summary of several key points in html learning. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

See all articles