search
HomeWeb Front-endCSS TutorialIntroduction to CSS block-level elements/inline elements, inheritance and related properties


What are block-level elements?

Browsers usually display block-level elements using line breaks before and after the element. You can visualize this as a bunch of boxes.
 Block-level elements always start on a new line and take up the full width available (expanding to the left and right as much as possible).
Usage: Block-level elements may only appear within the element.

What are inline elements?

In HTML, an inline element is one that occupies only the space bounded by the tag that defines the element, rather than disrupting the flow of the content. In this article, we will examine HTML inline elements and how they differ from block-level elements.
Inline elements do not start on a new line and only take up the necessary width.

What is inheritance?

Inheritance in CSS is the mechanism for passing certain properties from a parent element to its child elements.
Personal understanding: What factors are passed down from the parents to their children by default. Example: If both parents have black hair, their children will inherit black hair by default. Unless the child wants to dye his hair gray, let's talk about it separately. If it's not the child of that parent, let's talk about it separately.

Not all CSS properties are inherited, as some of them are meaningless. For example, margins are not inherited because child elements are unlikely 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 look at each property in the CSS 2.1 specification property summary table.

Attributes that can and cannot be inherited in CSS

1. Non-inheritable attributes
1. display: Specifies the type of box that the element should generate
2. Text attribute :
vertical-align: vertical text alignment
text-decoration: specifies the decoration added to the text
text-shadow: text shadow effect
white-space: processing of whitespace characters
unicode- bidi: Set the direction of the text
3. Box model attributes:
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 attributes:
background, background-color, background-image, background-repeat, background-position, background-attachment
5, positioning attributes:
float, clear, position, top, right, bottom, left, min-width, min-height, max-width, max-height, overflow, clip, z-index
6. Generate content attributes:
content、counter-reset、counter-increment
7、Outline style attributes:
outline-style、outline-width、outline-color、outline
8、Page style attributes:
size、 page-break-before, page-break-after
9, sound style attributes:
pause-before, pause-after, pause, cue-before, cue-after, cue, play-during

2. Inherited attributes
1. Font family attributes
font: combined font
font-family: specifies the font family of the element
font-weight: sets the thickness of the font
font-size: Set the size of the font
font-style: Define the style of the font
font-variant: Set the font for small uppercase letters to display text, which means that all lowercase letters will be converted to uppercase, but All letters using small caps have a smaller font size compared to the rest of the text.
font-stretch: Stretch and transform the current font-family. Not supported by all major browsers.
font-size-adjust: Specify an aspect value for an element so that the x-height of the preferred font is maintained.
2. Text series attributes
text-indent: text indent
text-align: text horizontal alignment
line-height: line height
word-spacing: increase or decrease the spacing between words White space (i.e. word spacing)
letter-spacing: increase or decrease the space between characters (character spacing)
text-transform: control text case
direction: specify the writing direction of text
color: Text color
3, element visibility: visibility
4, table layout attributes:
caption-side, border-collapse, border-spacing, empty-cells, table-layout
5, list layout Attributes:
list-style-type, list-style-image, list-style-position, list-style
6, generated content attributes: quotes
7, cursor attributes: cursor
8, Page style attributes:
page, page-break-inside, windows, orphans
9, Sound style attributes:
speak, speak-punctuation, speak-numeral, speak-header, speech-rate, volume, voice-family, pitch, pitch-range, stress, richness,, azimuth, elevation

3. Attributes that can be inherited by all elements
1. Element visibility: visibility
2. Cursor attributes: cursor

4. Attributes that can be inherited by inline elements
1. Font family attributes
2. Text series attributes except text-indent and text-align

5. Block-level elements Attributes that can be inherited
1, text-indent, text-alignnce_and_cascade#The_cascade

The above is the detailed content of Introduction to CSS block-level elements/inline elements, inheritance and related properties. For more information, please follow other related articles on the PHP Chinese website!

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
利用CSS怎么创建渐变色边框?5种方法分享利用CSS怎么创建渐变色边框?5种方法分享Oct 13, 2021 am 10:19 AM

利用CSS怎么创建渐变色边框?下面本篇文章给大家分享CSS实现渐变色边框的5种方法,希望对大家有所帮助!

css ul标签怎么去掉圆点css ul标签怎么去掉圆点Apr 25, 2022 pm 05:55 PM

在css中,可用list-style-type属性来去掉ul的圆点标记,语法为“ul{list-style-type:none}”;list-style-type属性可设置列表项标记的类型,当值为“none”可不定义标记,也可去除已有标记。

css与xml的区别是什么css与xml的区别是什么Apr 24, 2022 am 11:21 AM

区别是:css是层叠样式表单,是将样式信息与网页内容分离的一种标记语言,主要用来设计网页的样式,还可以对网页各元素进行格式化;xml是可扩展标记语言,是一种数据存储语言,用于使用简单的标记描述数据,将文档分成许多部件并对这些部件加以标识。

css3怎么实现鼠标隐藏效果css3怎么实现鼠标隐藏效果Apr 27, 2022 pm 05:20 PM

在css中,可以利用cursor属性实现鼠标隐藏效果,该属性用于定义鼠标指针放在一个元素边界范围内时所用的光标形状,当属性值设置为none时,就可以实现鼠标隐藏效果,语法为“元素{cursor:none}”。

rtl在css是什么意思rtl在css是什么意思Apr 24, 2022 am 11:07 AM

在css中,rtl是“right-to-left”的缩写,是从右往左的意思,指的是内联内容从右往左依次排布,是direction属性的一个属性值;该属性规定了文本的方向和书写方向,语法为“元素{direction:rtl}”。

css怎么设置i不是斜体css怎么设置i不是斜体Apr 20, 2022 am 10:36 AM

在css中,可以利用“font-style”属性设置i元素不是斜体样式,该属性用于指定文本的字体样式,当属性值设置为“normal”时,会显示元素的标准字体样式,语法为“i元素{font-style:normal}”。

css怎么实现英文小写转为大写css怎么实现英文小写转为大写Apr 25, 2022 pm 06:35 PM

转换方法:1、给英文元素添加“text-transform: uppercase;”样式,可将所有的英文字母都变成大写;2、给英文元素添加“text-transform:capitalize;”样式,可将英文文本中每个单词的首字母变为大写。

怎么设置rotate在css3的旋转中心点怎么设置rotate在css3的旋转中心点Apr 24, 2022 am 10:50 AM

在css3中,可以用“transform-origin”属性设置rotate的旋转中心点,该属性可更改转换元素的位置,第一个参数设置x轴的旋转位置,第二个参数设置y轴旋转位置,语法为“transform-origin:x轴位置 y轴位置”。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft