Home > Article > Web Front-end > How to write css tag style
In order to style a tag using CSS, follow these steps: Specify Tag Name: The name of the HTML tag to which the style will be applied. Set property: The style property to change, such as color, size, or margins. Specified value: A specific value for the attribute, such as red, 10px, or 50px.
CSS tag style writing method
CSS (Cascading Style Sheets) is a method used to describe the appearance and appearance of web pages. A style language for formatting. To specify a style for an HTML tag, use the following format:
<code class="css">标签名 { 属性: 值; 属性: 值; }</code>
Where:
represents a paragraph.
represents the text color.
means red.
Example:
To set red text in all paragraphs, you can use the following CSS rules:<code class="css">p { color: red; }</code>
property and Values
There are hundreds of properties and values in CSS that can be used to control various styling effects. The following are some commonly used properties and values:Properties:
: Text color
: Font size
: Background color
: Margin (distance from other elements )
: Padding (distance from the content within the element)
Value:
(e.g.
#ff0000 for red)
(e.g.
red)
(e.g.
10px)
(e.g.
50%)
(e.g.
auto,
inherit)
Style priority
When multiple CSS rules apply to the same element, the rule with the highest priority will be applied. Priority is determined by the following factors:Applying Styles
Styles can be applied in three locations: file and then linked to the HTML document via the
tag.