What is the use of quote in CSS


#1


Lesson 22

There are two versions of the same piece of HTML. One comes with quote for the selectors and the other one does not. However they all produce the same result instead of giving me an error (I suppose the one comes without quote should give me the error). I am wondering what is the use of quote in HTML in terms of selectors if it is an option from syntax.


The version without quote:

<!DOCTYPE html>
<html>
	<head>
		<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
		<title>Result</title>
	</head>
	<body>
		<!--Add your HTML below!-->
		<h3 class=fancy> This is a fancy h3!</h3>
		<p class=fancy> this is the P line.</p>
		<p id=serious> this is my line.</p>
	</body>
</html>

The version with quote:

<!DOCTYPE html>
<html>
	<head>
		<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
		<title>Result</title>
	</head>
	<body>
		<!--Add your HTML below!-->
		<h3 class="fancy"> This is a fancy h3!</h3>
		<p class="fancy"> this is the P line.</p>
		<p id="serious"> this is my line.</p>
	</body>
</html>

In CSS:

.fancy{
    font-family:cursive;
    color:violet;
}

#serious{
    color:#8C8C8C;
    font-family:Courier;}


#2

with the latest html5 standards, the quotation marks are no longer required, so you can (in some cases) leave them out.

Before html5 they where mandetory, i am sure you can find documentation online on when you can leave them out


#3

Not so. HTML 4 allowed unquoted attributes (with no white space). Only XML compliant markup requires quoted attributes, so that would be XHTML or HTML5 for XML. HTML5 served as text/html can go either way. Quotes are a best practice, though, so we shouldn't develop lazy habits if we can avoid it.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.