📌  相关文章
📜  elemento SPAN - CSS (1)

📅  最后修改于: 2023-12-03 15:14:51.571000             🧑  作者: Mango

Introduction to the SPAN element in CSS

The SPAN element in HTML is used to group inline elements and apply CSS styles to them. It is typically used when you want to style a part of a text, such as changing the color, font size or weight.

To style the SPAN element, you can use the CSS span selector. Here's an example:

span {
    color: red;
    font-size: 12px;
    font-weight: bold;
}

This will apply the specified styles to all SPAN elements on the page. However, it is more common to use a class or ID selector to target specific SPAN elements.

<p>This is some <span class="highlight">highlighted</span> text.</p>
.highlight {
    color: blue;
    font-size: 16px;
    font-weight: normal;
}

In this example, the SPAN element with the class "highlight" will be styled with the specified properties.

Note that the SPAN element is an inline element, which means it will not create a new line in the text. If you want to apply styles to a block of text, you should use a block-level element, such as DIV.

Overall, the SPAN element is a versatile tool for applying fine-grained styling to specific parts of a page.