Quotes Or Apostrophes

Here’s the exercise (even though its a general HTML questions) l: https://www.codecademy.com/courses/learn-css/lessons/learn-css-selectors/exercises/multiple-classes
<link href='style.css' rel='stylesheet'>

I just got done doing HTML exercises, and where you see apostrophes(for some reason sometimes(in life, not just in code) they’re used as quotation marks) in the above code copied from a CSS exercise, there was always actual quotation marks in the HTML exercises. Why did it change? I love the exercises here, but one problem I have is things being introduced without being explained as if they expect us to be familiar with them even though they wouldn’t be covered until a later exercise. That happened a couple times during the HTML exercises, but I can’t remember what it was that was mentioned but not covered yet. And the code editor auto completes both, which means they’re both standard. Why? One of my instructors mentioned that there’s a debate about " vs ’ in the coding community because sometimes when you use one as a quotation mark, it doesn’t work. Why not just end the debate and stop using apostrophes as quotation marks, or just use that. Why use both and confuse the situation? Who uses apostrophes as quotation marks as a standard practice anyway? British people? Canadians?
Thank You

Here’s " vs ’ explained.

Why can’t we preview a post?

Edit: Is the other character that’s on the key with the ~ a single quotation mark?

1 Like

Either is valid. The purists among us are rather attached to the double quotes in HTML, and single quotes in CSS and ticks in JS, but it really does not matter, either way. You’ll hear over and over again, be consistent.

If you end up on a team, there will naturally be a style guide that the whole team follows, so the decision is already made for you. Personally, I like double quotes in HTML, and pretty much stick with that.

<p lang="en">Hello World!</p>
body {
    background-image: url('home-bg.png');
}
const g = `Hello World!`;
console.log(`<p lang="en">${g}</p>`);
3 Likes

It just occurred to me. Maybe the person who made the HTML exercises is a different person than who made the CSS exercises and one normally uses " and the other uses ’ and they do it so second naturedly that they don’t even think about the other one.

1 Like

It would not be difficult to agree with your observation. The left hand does not know what the right hand is doing. CC doesn’t have a style guide that I’m aware of.

What our largest concern is relates to readability and easy debugging. It is super easy to gloss over a missing quote, or mismatched quote when no consistency can be expected. If we’re always looking for double quotes in pairs around attributes, it’s a breeze to spot typos and other tiny errors in our markup.

A good lot of the HTML delivered today is in the form of dynamically drawn together response pages that take data and embed it in one or more merged templates. The result is an HTML document that can then be sent down to the client. Back in the day, all of my PHP generated responses were W3C valid and WAI-WCAG compliant, and followed my own strict standard… double quotes in HTML. When JS was used to generate HTML, it wrote single quotes. That way it was easy for me to see the client side generation, versus the server side delivery in page source code.

Oops…

console.log(`<p lang='en'>${g}</p>`);

[quote=“mtf, post:4, topic:811886, full:true”]The left hand does not know what the right hand is doing.
[/quote]I hope you don’t mean that more negatively than my complaint is. The biggest problem I have is going form one quotation type to the other without explaining why. My observation is probably why that happened. Since they both work, its otherwise not worth worrying about. Just don’t surprise me and act like its not a surprise. That’s all I ask.

Edit: Why is the quote tag not working above?

Not negative, at all. Authors have literally been working from the seat of their pants, and rushing out new products at a steady pace as their curriculum bosses order. I don’t believe there is a common style guide, only advisors on what the narrative should say and what their code should be doing. Each author has their own style, which is evidenced by the differences. It is not a bad thing, just more left hand-right hand independent.

In any large organization there is going to be staff turn-over. Authors and curriculum advisors come and go, each with their own ideas and methodologies. Nobody is intentionally surprising anybody. It’s just the way things turn out to appear.

Also note, we members cannot speak for CC, or the inner workings, and have no hand in course creation or management of this forum. As for the quote above, I have no explanation. If you can still edit it, try opening it, shift your text down a line or two and see what happens in the preview window.

I just had an instance where the double quotes didn’t work but the single quotes did :confused:: It was in this lesson: https://www.codecademy.com/courses/learn-css/lessons/css-typography/exercises/web-fonts-using-link

space { 
  font-family: 'Space Mono', monospace;
{

LOL

Edit: The lessons about fonts strongly encourage you to put multi word font names in quotes, but don’t say you’re required to. Apparently you’re required to.

1 Like