Introduction to CSS block-level elements/inline elements, inheritance, and related properties

Source: Internet
Author: User


What is a block-level element (Block-level elements)?

Browsers typically use line breaks to display block-level elements before and after elements. You can visualize it as a bunch of boxes.
Block-level elements always start on new lines and occupy the full width available (extend as far as possible to the left and right).
Usage: block-level elements may appear only <body> within an element.

What is an inline element (inline elements)?

In HTML, inline elements are only spaces that occupy the label defined by the definition element, not the stream that destroys the content. In this article, we examine the HTML inline elements and their differences from block-level elements.
Inline elements do not start on new lines, and only occupy the necessary width.

What is inheritance (inheritance)?

Inheritance in CSS is the mechanism by which certain attributes are passed from the parent element to its child elements.
Personal Understanding: What are the factors of the parents, the default inheritance to the sub-generation what factors. Example: Parents are black hair, the default inheritance to children black hair. Unless the child wants to dye grey hair and talk, not the parent's child to talk about otherwise.

Not all CSS properties are inherited, because some of them are meaningless. For example, margins are not inherited because child elements are less likely to need the same margins as their parent elements. In most cases, common sense will tell you which properties are inherited and which are not, but you do need to see each of the properties in the CSS 2.1 specification property Summary table.

Properties that can and cannot be inherited in CSS

I. Attributes with no inheritance
1. Display: Specifies the type of box that the element should generate
2. Text properties:
Vertical-align: Vertical Text alignment
Text-decoration: Specifies decorations added to the text
Text-shadow: Text Shadow Effect
White-space: processing of whitespace characters
Unicode-bidi: Setting the direction of text
3. Properties of the box model:
width, height, margin, margin-top, Margin-right, Margin-bottom, Margin-left, Border, Border-style, Border-top-style, Border-right-style, Border-bottom-style, Border-left-style, Border-width, Border-top-width, Border-right-right, Border-bottom-width, Border-left-width, Border-color, Border-top-color, Border-right-color, Border-bottom-color, Border-left-color, Border-top, Border-right, Border-bottom, Border-left, padding, padding-top, Padding-right, Padding-bottom, Padding-left
4. Background properties:
Background, Background-color, Background-image, Background-repeat, Background-position, background-attachment
5. Positioning Properties:
Float, clear, position, top, right, bottom, left, Min-width, Min-height, Max-width, max-height, overflow, clip, Z-index
6. Generate Content Properties:
Content, Counter-reset, counter-increment
7. Contour Style Properties:
Outline-style, Outline-width, Outline-color, outline
8. Page Style properties:
Size, Page-break-before, Page-break-after
9. Sound style properties:
Pause-before, Pause-after, pause, Cue-before, Cue-after, Cue, play-during

Second, inherited properties
1, font family Properties
Font: Combined font
font-family: Font family of specified elements
Font-weight: Setting the weight of the font
Font-size: Setting the size of the font
Font-style: Defines the style of the font
Font-variant: Sets the font display text for small caps, which means that all lowercase letters are converted to uppercase, but all letters that use a small uppercase font have a smaller font size than the rest of the text.
Font-stretch: The current font-family is stretched and deformed. All major browsers are not supported.
Font-size-adjust: Specify a aspect value for an element so that the x-height of the preferred font can be maintained.
2, Text series Properties
Text-indent: Text indent
text-align: Text horizontal alignment
Line-height: line height
word-spacing: Increase or decrease whitespace between words (that is, word spacing)
Letter-spacing: Increase or decrease whitespace between characters (character spacing)
Text-transform: Control text Case
Direction: Specifies the direction in which the text is written
color: text color
3, Element Visibility: Visibility
4, table layout properties:
Caption-side, Border-collapse, border-spacing, Empty-cells, Table-layout
5, List Layout properties:
List-style-type, List-style-image, List-style-position, List-style
6, build content properties: Quotes
7, cursor properties: Cursor
8, page style properties:
page, Page-break-inside, Windows, orphans
9, Sound style properties:
Speak, Speak-punctuation, speak-numeral, Speak-header, Speech-rate, volume, voice-family, pitch, pitch-range, stress, richness, azimuth, elevation

Iii. attributes that all elements can inherit
1. Element Visibility: Visibility
2, cursor properties: Cursor

Iv. attributes that can be inherited by inline elements
1. Font family Properties
2. Text Series properties except Text-indent, Text-align

V. Attributes that block-level elements can inherit
1, Text-indent, Text-alignnce_and_cascade#the_cascade

Related Article

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.