Differences between block and inline Elements

Source: Internet
Author: User

Only one row can set the margin in the width, height, and vertical direction, and the margin and padding in the horizontal direction of padding.

Block Element: Yes, yes, yes

 

Inline element: No, no

 

 

Question: Change the nine days of the next poem to a red font.

The sunshine incense burner produces Ziyan, And the waterfall hangs down in qianchuan.
Flying down three thousand feet, suspected to be nine days of Galaxy.

 

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
<Style>
# Jiutian {
Color: red;
}
</Style>
</Head>
<Body>
<Div>
The sunshine incense burner produces Ziyan, And the waterfall hangs down in qianchuan.
Flying down three thousand feet, suspected to be galaxy falls <Div id = "jiutian"> nine days </div>.
</Div>
</Body>
</Html>

 

NOTE: If div is used, text can be displayed in red, but new lines will be generated.

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Style>
# Jiutian {
Color: red;
}
</Style>
</Head>
<Body>
<Div>
The sunshine incense burner produces Ziyan, And the waterfall hangs down in qianchuan.
Flying down three thousand feet, suspected to be galaxy falls <span id = "jiutian"> nine days </span>.
</Div>
</Body>
</Html>

Note: Use the inline element span to implement the requirements.

Inline block conversion BRICK: Set display: block; block to inline: Set display: inline

* ***** What elements in HTML are block and inline ???

Block Element)
· Address-address
· BLOCKQUOTE-block reference
· Center-align Blocks
· Dir-directory list
· Div-common block level is easy and is also the main tag of CSS layout
· DL-definition list
· Fieldset-Form Control Group
· Form-interactive form
· H1-large title
· H2-subtitle
· H3-Level 3 title
· H4-4 level title
· H5-Level 5 Title
· H6-6 level title
· Hr-horizontal Separator
· Isindex-input prompt
· Menu-Menu list
· Noframes-frames (this block content is displayed in browsers that do not support frame)
· NoScript-optional script content (this content is displayed in browsers that do not support scripts)
· Ol-sorting form
· P-paragraph
· Pre-format text
· Table-table
· Ul-non-sorted list

Inline Element)
· A-anchor
· Abbr-abbreviation
· Acronym-First word
· B-bold (not recommended)
· BDO-bidi override
· Big-large font
· Br-line feed
· CITE-Reference
· Code-computer code (required when source code is referenced)
· Dfn-define Fields
· Em-emphasis
· Font-font setting (not recommended)
· I-italic
· IMG-Image
· Input-input box
· KBD-define keyboard text
· Label-Table label
· Q-short reference
· S-hyphen (not recommended)
· Samp-Define sample computer code
· Select-Project Selection
· Small-small font text
· Span-common inline containers that define text blocks
· Strike-strike
· Strong-highlighted in bold
· Sub-subscript
· Sup-superscript
· Textarea-multi-line text input box
· Tt-telex text
· U-underline
· Var-define variables

 

When inline elements define one of the following attributes in CSS, they have the features of block elements.
1) display: block;
2) float: Left; (not only has the features of block elements, but also floats on the left)
However, the inline elements at this time have the features of block elements, but there is a difference between the two. The first one is exactly the same as the block elements. Each element occupies a single row, from left to right, without the properties of width and height, strictly follow the flow mode of block elements in the flow layout model. It flows from top to bottom. Second, the size is exactly the content that can be included, and the right side floats, it can be multiple rows.
 
When position: absolute/relative is added, block and inline elements are not restricted by the parent region. You can move them to any position. If the width and height attributes are added, then it has the features of layers. (The benefits of width and height are that they are compatible with IE browsers. The actual effects of all browsers are the same)

 

Block elements are generally the container elements of other elements. Block elements generally start from a new line and can accommodate inline elements and other block elements) it is generally a basic element based on the semantic level (semantic. Inline elements can only contain text or other inline Elements

Block elements are generally the container elements of other elements. Block elements generally start from a new line and can accommodate inline elements and other block elements, the common block element is the section label 'P ". The "form" block element is special. It can only accommodate other block elements.
If no CSS function is available, the block elements are arranged in the order of each row. With CSS, we can change the default layout of HTML and place block elements in the desired position. Instead of just starting another line. It should be noted that table labels are also a type of block elements. Table based layout and cssbased layout refer to these two layout s from the perspective of general users (excluding persons with visual impairment and blind persons, there is no difference except for the page loading speed. However, if a common user inadvertently clicks the page source code button, the difference between the two is very large. The CSS layout page source code, designed based on a good refactoring concept, can at least allow common users without web development experience to quickly understand the content. From this perspective, CSS layout code should have a better aesthetic experience.
You can think of the block container element Div as a box, or it is easier to understand if you have played the clipboard. First, we cut down the necessary articles from various newspapers and magazines. Each piece of cut is a block. Then we pasted the paper block to a blank new paper with glue based on our typographical intent. This forms your own unique digest Express. As an extension of technology, webpage layout design follows the same pattern.

Inline elements are generally basic elements based on the semantic level (semantic. Inline elements can only contain text or other inline elements. Common inline elements are "".
It should be noted that the Chinese name of inline element has multiple inline elements, embedded elements, in-line elements, and straight-forward elements. Basically, there is no unified translation. What do you call love. When we mention inline elements, we will think of a display attribute: Display: inline; which can fix the famous IE Double Floating boundary.
Both block element and inline element are concepts in the HTML specification. The basic difference between block elements and inline elements is that block elements generally start from a new line. After CSS control is added, the attribute differences between block elements and inline elements will not be different. For example, we can add the inline element cite to the display: block attribute so that it also has attributes starting from the new line each time.

 


When inline elements define one of the following attributes in CSS, they have the features of block elements.
1) display: block;
2) float: Left; (not only has the features of block elements, but also floats on the left)
However, the inline elements at this time have the features of block elements, but there is a difference between the two. The first one is exactly the same as the block elements. Each element occupies a single row, from left to right, without the properties of width and height, strictly follow the flow mode of block elements in the flow layout model. It flows from top to bottom. Second, the size is exactly the content that can be included, and the right side floats, it can be multiple rows.
 
When position: absolute/relative is added, block and inline elements are not restricted by the parent region. You can move them to any position. If the width and height attributes are added, then it has the features of layers. (The benefits of width and height are that they are compatible with IE, and the actual effects of all browsers are the same.) When inline elements are defined in CSS, one of the following attributes is defined, it has the features of block elements.
1) display: block;
2) float: Left; (not only has the features of block elements, but also floats on the left)
However, the inline elements at this time have the features of block elements, but there is a difference between the two. The first one is exactly the same as the block elements. Each element occupies a single row, from left to right, without the properties of width and height, strictly follow the flow mode of block elements in the flow layout model. It flows from top to bottom. Second, the size is exactly the content that can be included, and the right side floats, it can be multiple rows.
 
When position: absolute/relative is added, block and inline elements are not restricted by the parent region. You can move them to any position. If the width and height attributes are added, then it has the features of layers. (The benefits of width and height are that they are compatible with IE, and the actual effects of all browsers are the same.) When inline elements are defined in CSS, one of the following attributes is defined, it has the features of block elements.
1) display: block;
2) float: Left; (not only has the features of block elements, but also floats on the left)
However, the inline elements at this time have the features of block elements, but there is a difference between the two. The first one is exactly the same as the block elements. Each element occupies a single row, from left to right, without the properties of width and height, strictly follow the flow mode of block elements in the flow layout model. It flows from top to bottom. Second, the size is exactly the content that can be included, and the right side floats, it can be multiple rows.

When position: absolute/relative is added, block and inline elements are not restricted by the parent region. You can move them to any position. If the width and height attributes are added, then it has the features of layers. (The benefits of width and height are that they are compatible with IE, and the actual effects of all browsers are the same.) When inline elements are defined in CSS, one of the following attributes is defined, it has the features of block elements.
1) display: block;
2) float: Left; (not only has the features of block elements, but also floats on the left)
However, the inline elements at this time have the features of block elements, but there is a difference between the two. The first one is exactly the same as the block elements. Each element occupies a single row, from left to right, without the properties of width and height, strictly follow the flow mode of block elements in the flow layout model. It flows from top to bottom. Second, the size is exactly the content that can be included, and the right side floats, it can be multiple rows.

When position: absolute/relative is added, block and inline elements are not restricted by the parent region. You can move them to any position. If the width and height attributes are added, then it has the features of layers. (The benefits of width and height are that they are compatible with IE, and the actual effects of all browsers are the same.) When inline elements are defined in CSS, one of the following attributes is defined, it has the features of block elements.
1) display: block;
2) float: Left; (not only has the features of block elements, but also floats on the left)
However, the inline elements at this time have the features of block elements, but there is a difference between the two. The first one is exactly the same as the block elements. Each element occupies a single row, from left to right, without the properties of width and height, strictly follow the flow mode of block elements in the flow layout model. It flows from top to bottom. Second, the size is exactly the content that can be included, and the right side floats, it can be multiple rows.

When position: absolute/relative is added, block and inline elements are not restricted by the parent region. You can move them to any position. If the width and height attributes are added, then it has the features of layers. (The benefits of width and height are that they are compatible with IE, and the actual effects of all browsers are the same.) When inline elements are defined in CSS, one of the following attributes is defined, it has the features of block elements.
1) display: block;
2) float: Left; (not only has the features of block elements, but also floats on the left)
However, the inline elements at this time have the features of block elements, but there is a difference between the two. The first one is exactly the same as the block elements. Each element occupies a single row, from left to right, without the properties of width and height, strictly follow the flow mode of block elements in the flow layout model. It flows from top to bottom. Second, the size is exactly the content that can be included, and the right side floats, it can be multiple rows.

When position: absolute/relative is added, block and inline elements are not restricted by the parent region. You can move them to any position. If the width and height attributes are added, then it has the features of layers. (The benefits of width and height are that they are compatible with IE browsers. The actual effects of all browsers are the same)

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.