This forum is now read-only. Please use our new forums at

200 points
Submitted by
about 4 years ago

Why do i have to add a semicolon?

h1 {
text-align: center;
color: orange

<h1>Why do I have to add a semicolon in the following?</h1>

("h1 {
    text-align: center--> ; <--
"h1 {
    text-align: center;

also, <!DOCTYPE html>
what does the <! mean because i saw it in <!-- for comments

1 vote


CSS rules contain property-value pairs followed by a semicolon. The last declaration doesn't need a semicolon but not using one could make it easier than necessary to create a bug in your code. When you decide to add another declaration to your previous rule, you can easily forget to add the semicolon that you had previously left off.

About the ! in <!DOCTYPE html>, I can't find anywhere that explains why, only that it is part of the HTML Standard.

3698 points
Submitted by
about 4 years ago

1 Comment

592fe79310732d3f5222bba0cc5ed1f6?s=140&d=retro thexmitchell about 4 years ago

okay thanks :D