This example shown below that's add a class attribute to an HTML tag so thats you can directly access to it.
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.nav {
padding-left: 12px;
}
</style>
</head>
<body>
<ul class="nav">
<li><a href="home.html">Home</a></li>
<li><a href="home.html">Blog</a></li>
</ul>
</body>
Classes can be used to interchangeably with tags, so the descendant selectors work doesnt change.
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.nav a {
color: blue;
text-decoration: none;
}
</style>
</head>
<body>
<ul class="nav">
<li><a href="home.html">Home</a></li>
<li><a href="home.html">Blog</a></li>
</ul>
</body>
This selectors says find all a tags that are childreen of any tag with a class of nav
Generally speaking, first declare broadest rule with type selector, and then get more specific with class selectors. these example like this following css code:
ul {
padding: 10px 0 0 0px;
}
.nav{
padding: 0; // reset all padding in .nav
}
div is short for division, and it's a block-level tag that's a generic way to group related content into sections on a page.
The width and height of any tag's content can be changed in CSS.