Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Quotation marks

Why are some of the attributes, tittles and phrases put in quotation marks ? What is the purpose of the quotation marks or why do we used them in our coding

They are put in quotation marks so you can input spaces between words without breaking the semantic. If you don't use a quotation mark and you use space between words, the browser validator would see the separated words as html attributes, and could lead to a broken page.

A link title like:

<a href="#" title="My Awesome Title" ></a> 

work as intended, but if you remove the quotation marks, the title would be only the word "My", with invalid code Awesome and Title set as html attributes without value:

<a href=# title=My Awesome Title ></a>

and then you would not only failed to show the correct title, but also produced invalid code, and a w3c validation would fail with the message: "AWESOME" / "TITLE" is not a member of a group specified for any attribute.

You can always check at http://validator.w3.org/

Hope that helps :)

2 Answers

In HTML tags, quotation marks tell the browser, “This is the value we want to assign to this property.” For example:

<body bgcolor="blue">
    <h1>Welcome to Shirts 4 Mike!</h1>
    <p>Check out my <a href="newshirt.html">latest shirt</a>! It's on sale for just <span class="price">$10</span>!</p>
</body>

However, if you need to wrap regular text in quotation marks, it is recommended (as well as good practice) to use the special HTML code: & quot; (without the space). For instance, if you wanted to tell your visitors that you're learning a new language:

<p>Today, I began taking a new course. Pretty soon, I'll be able to say "Hello world!" using JavaScript!</p>

Thank you Eddie this is much clearer now