CSS tags
In CSS, tags are used to select and style HTML elements. Here are some common CSS tags:
body
: Applies styles to the entire body of the documenth1
,h2
,h3
,h4
,h5
,h6
: Selects heading elements and allows you to style them accordinglyp
: Targets paragraphs and allows you to style thema
: Used to select and style hyperlink tagsimg
: Targets image tags and allows you to style themul
,ol
: Targets unordered and ordered list elements respectively and allows you to style themli
: Targets list items within a list and allow you to style themdiv
: Used to create a container element that you can then style, often used for layoutsspan
: Similar todiv
, but used to select inline elements, such as text or images, rather than creating a container element
Here's an example of applying styles to the h1
and p
tags:
h1 {
color: red;
font-family: Arial, sans-serif;
}
p {
color: #333;
font-size: 18px;
line-height: 1.5;
}
In this example, we're setting the text color and font family of all <h1>
elements to red and Arial, respectively. For <p>
elements, we're setting the text color to a darker gray, increasing the font size to 18 pixels, and setting the line height to 1.5.