The difference between block elements and inline elements.
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)
What is the difference between inline elements and block-level elements in CSS?
Block-level elements are classified into three types based on their application structure or content: Structured block elements, terminal block elements, and multi-object block elements. 1. Structured block elements are used to construct the structure of a document. A good document structure is very advantageous for search engines and other technologies (such as JavaScript. They do not have a semantic meaning. They only define the document organization mode and do not reflect the document content. Major structured block elements <ol> <ul> <dl> <table> support for structured elements <li> <dt> <dd> <caption> <thead> <tbody> <tfoot> <colgroup> <col> 2. elements such as terminal block elements are used to shift from structure to content. They have semantic meanings and can indicate the nature of the content. Terminal block elements are the endpoints of the structure. They cannot contain other block-level elements, but can only contain text or row-level elements. Terminal Block Element
Q: What is the difference between inline elements and block-level elements in HTML?
The main difference is:
Inline does not occupy rows, such as input, span, and a. You will find that when multiple inputs are written, they are all placed in the same row.
Block elements that occupy rows, such as div and p. You will find that when writing multiple Divs, each of them occupies one row.
Sometimes you may observe what elements you use. You can also go to w3school.
If you want to inline elements to occupy rows, you can use the display: block in css;
Hope to help you