This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by thexmitchell
almost 10 years

Why do i have to add a semicolon?

<style>
h1 {
text-align: center;
color: orange
}

</style>
<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

Answer 535d739e548c35caa7002495

1 vote

Permalink

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.

points
Submitted by Judy
almost 10 years

1 comments

thexmitchell almost 10 years

okay thanks :D