In HTML, HTML tag elements are roughly classified into three different types: inline elements (also known as the line element), a block element, inline block elements.
Common inline elements include:
<a>、<span>、<br />、<i>、<em>、 <strong>、<label>、<q>、<var>、<cite>、<code>
The characteristics of inline elements:
- And other inline elements are displayed on the same line
- Width, height, top and bottom margins of the element can not be set
- The width of the elements is that it contains text or image width can not be changed
CSS code by display: inline element is set to the inline elements:
div {
display: inline;
}
Commonly used block elements are:
<div>、<p>、<h1>…<h6 />、<ul>、<ol>、 <table>、<address>、<blockquote>、<form>
Block element features:
- Each block element begins a new line, and the subsequent cut is also a separate line element (a block element on a separate line)
- Width, height, top and bottom margins can be set elements
- Width of the element is not provided in the case of 100% of his own parent container
CSS code by display: block element is set to the block elements:
div {
display: block;
}
Common inline block elements are:
<img>、<input>
Inline block element features:
- Or other inline elements and inline block elements are displayed on the same line
- Width, height, top and bottom margins can be set elements
CSS code by display: inline-block element to the inline block elements:
div {
display: inline-block;
}