0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<p>Do you remember that we learned about tag and class selectors in the second step? And that we even tried to apply styles to one of the tags, nav? The size of our project is growing, and consequently the number of styles is increasing, so it’s time to figure out how to better use these selectors to avoid mistakes in the future.</p>
1
<p>Do you remember that we learned about tag and class selectors in the second step? And that we even tried to apply styles to one of the tags, nav? The size of our project is growing, and consequently the number of styles is increasing, so it’s time to figure out how to better use these selectors to avoid mistakes in the future.</p>
2
<p>Imagine that you need to apply styles to a list, ul. It would seem that you should be able to do the following, and that would be the end of the matter:</p>
2
<p>Imagine that you need to apply styles to a list, ul. It would seem that you should be able to do the following, and that would be the end of the matter:</p>
3
ul { property: value; }<p>But there can be several lists on a page. With the proposed code, the styles will be applied to all of the lists, including the ones that we don’t want to change. In order to avoid such situations, it would be best for us not to use tag selectors or to try to use them as rarely as possible.</p>
3
ul { property: value; }<p>But there can be several lists on a page. With the proposed code, the styles will be applied to all of the lists, including the ones that we don’t want to change. In order to avoid such situations, it would be best for us not to use tag selectors or to try to use them as rarely as possible.</p>
4
<p>An excellent solution to our problem is to use a class selector. By adding the desired class to the markup element, we can be certain that the styles will be applied to just this element and not to any others.</p>
4
<p>An excellent solution to our problem is to use a class selector. By adding the desired class to the markup element, we can be certain that the styles will be applied to just this element and not to any others.</p>
5
<p>Let’s make a slight improvement to the code in the CSS rule for the navigation by replacing the tag selector with the class selector.</p>
5
<p>Let’s make a slight improvement to the code in the CSS rule for the navigation by replacing the tag selector with the class selector.</p>