I've been working with CSS for sometime and I see that in a lot of tutorials and exercises the last line of a CSS tag has no ";" added to it. For example:
ul li:hover ul {
display: block
}
ul li ul {
list-style: none;
position: absolute;
display: none;
width: 104px;
height: 100px;
background-image: url(../_img/nav/dropdownbg.1.png);
background-repeat: no-repeat;
background-position: center;
background-position: top
}
As you can see there are two examples. One with only one line and another with different commands in one tag. I would like to know why and which reason is there to do this?!! At school they didn;t tell us anything about this. I just close the last or only line with and ";" and it works perfectly.
So, which is the reason to do this? Is it more safe?
Šime Vidas' response to a related question is also valid here. The semicolon is a delimiter so the final property does not need to be delimited.
However, I would not recommend it, because in the scenario that you need to add another property to the end of a CSS rule it is far more likely that you'll miss out the need for a semicolon and your CSS will break.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With