DEV Community

Cover image for Quotation Marks, Single or Double?
Anita Olsen
Anita Olsen Subscriber

Posted on

Quotation Marks, Single or Double?

Which type of quotation marks are the best or the right ones to use, the single or the double ones? I tend to use double quotation marks because I find those easier to find and use on my Scandinavian keyboard (they do not share the same key) but I would love to hear what you guys suggest.

For example in Python:
print("Hello world!")
print('Hello world!')

Quotation marks, single or double? Which ones do you use and why?

Top comments (10)

Collapse
 
moopet profile image
Ben Sinclair

Single- and double quotes behave differently depending on the language you're using. For example, in PHP, variables are interpreted inside double-quotes:


$name = "Ben";

echo "Hello $name";
// Hello Ben

echo 'Hello $name';
// Hello $name
Enter fullscreen mode Exit fullscreen mode

So single-quotes are I suppose infinitesimally faster. Don't worry about that.
For general text, use double-quotes, because you're way more likely to use a single-quote as a substitute for an apostrophe in blocks of text than you are to include a quotation.

Collapse
 
pauljlucas profile image
Info Comment hidden by post author - thread only accessible via permalink
Paul J. Lucas

Single and double quotes mean totally different things in languages like C and C++.

The OP's question is ill-formed.

Collapse
 
lexlohr profile image
Info Comment hidden by post author - thread only accessible via permalink
Alex Lohr

Just use the default settings of Prettier and stop overthinking things.

Collapse
 
montyharper profile image
Monty Harper

Single quotes (in English) are typically used for a quote within a quote. For example: I told my friend, "According to California State University San Marcos (my online source), 'Single Quotation Marks are used to indicate dialogue within another quotation.'"

Collapse
 
ranjancse profile image
Ranjan Dailata • Edited

Double quotes are perfectly fine, I do use them from time to time on my own blog posts. Any quotes of interest can be technically represented using double quotes. However, with the Markdown format, one should use ">" symbol as shown below.

This is a quote

Collapse
 
coderhgw profile image
coderhgw

I perfer single

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
arindam-sahoo profile image
Arindam Sahoo • Edited

As long as an English Teacher is not having a look at your code, it's fine. Jk, You can use any of them if you are using programming languages like Python, JS, etc. What I did when I shifted from Java, I used single quotations for characters and double quotations for strings 'coz of my habit. And, now I use the one that does not let me overthink.

Collapse
 
decker67 profile image
decker

Single

Some comments have been hidden by the post's author - find out more