Home >Web Front-end >HTML Tutorial >What are inline elements and block-level elements? _html/css_WEB-ITnose
1. What are inline elements and block-level elements?
Block-level elements
information on author | |||||||||||||||||
long quotation | |||||||||||||||||
push button | |||||||||||||||||
table caption | |||||||||||||||||
definition description | |||||||||||||||||
deleted text | |||||||||||||||||
generic language/style container | |||||||||||||||||
definition list | |||||||||||||||||
definition term | |||||||||||||||||
form control group | |||||||||||||||||
interactive form | |||||||||||||||||
heading | |||||||||||||||||
heading | |||||||||||||||||
heading | |||||||||||||||||
heading | |||||||||||||||||
heading | |||||||||||||||||
heading | |||||||||||||||||
horizontal rule | |||||||||||||||||
inline subwindow | |||||||||||||||||
inserted text | |||||||||||||||||
fieldset legend | |||||||||||||||||
list item | |||||||||||||||||
client-side image map | |||||||||||||||||
alternate content container for non frame-based rendering | |||||||||||||||||
alternate content container for non script-based rendering | |||||||||||||||||
generic embedded object | |||||||||||||||||
ordered list | |||||||||||||||||
paragraph | |||||||||||||||||
preformatted text | |||||||||||||||||
Inline elements 2. What is the difference between inline elements and block-level elements? 1.Size - an important difference between block-level elements and inline elements inline elements and width The W3C CSS2 standard stipulates that the width attribute will not be applied to inline elements and non-replacement elements. In the following example, width:200px is applied to the inline element . As you can see, it has no effect at all. Inline elements and height The W3C CSS2 standard stipulates that the height attribute will not be applied to inline elements and non-replacement elements, but the box height can be passed through line -height to specify. In the following example, height:50px is applied to the inline element . You can see that there is no effect. Inline elements and padding You can set padding for inline elements, but only padding-left and padding-right take effect. In the following example, the inline element has padding:50px applied. You can see that it affects the left and right content, but not the top and bottom. Inline elements and margin The margin attribute is the same as the padding attribute. It is valid for the left and right of inline elements, but not for the top and bottom. In the example below, margin:50px is applied to . You can see that the left and right edges are effective but the top and bottom content are not. Remember that setting width for inline elements has no effect. The above part is translated from: http://www.maxdesign.com.au/ presentation/inline/
2. The text-align attribute is the difference between the two expressions in the W3C CSS2.1 specification Section 16.2 describes text-align in detail: If the inline content within the center-aligned child element does not need to be center-aligned, you also need to set "text-align:left" for it:
Statement: 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 Previous article:CSS3 media queries for iPhone_html/css_WEB-ITnoseNext article:CSS3 media queries for iPhone_html/css_WEB-ITnose |