Joke Collection Website - Bulletin headlines - Span style alignment in CSS

Span style alignment in CSS

Span element is an embedded element with no width feature. Setting the text-align attribute has no effect, so it is necessary to convert the display type of the span element into a block-level feature.

Method 1: Set the display property of span to block.

& ltspan style = " font-size: 14px; Text alignment: centered; Show: block; " & gt...& lt/span>。

Method 2: Set the display attribute of span to inline-block, which requires setting the width of span manually.

& ltspan style = " font-size: 14px; Text alignment: centered; Display: embedded-block; Width: 500 pixels; " & gt...& lt/span>。

Extended data

According to the display form of elements, html tags are mainly divided into block elements and inline elements.

Characteristics of massive elements:

1, always starting from a new line.

2. You can control the height, line height, outer margin and inner margin.

3. Unless the width is set, the default width is 100% of its container.

4. It can accommodate in-line elements and other block elements.

Embedded element function:

1, all other elements are on one line.

2. The height, outer margin and inner margin cannot be changed.

3. The width is the width of its text or picture and cannot be changed.

4. In-line elements can only save text or other in-line elements.

References:

Baidu Encyclopedia-Block Elements

Baidu encyclopedia-inline elements