CSS: When to use quotation marks & where to use the semi-colon? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

CSS: When to use quotation marks & where to use the semi-colon?

Hi all, I just wanted to check when and where it's appropriate to use quotation marks for CSS. Do you only use quotation marks when performing inline styling and internal styling? I presume it is not necessary to use quotation marks on external CSS stylesheets? The second part of my question is where it's appropriate to use the semi-colon. Does it matter if the semi-colon, placed at the end of each styling instruction, is placed inside the speech mark or outside the speech mark? Examples of both: <p style="color:blue";> <p style="color:blue;"> Thanks in advance to anybody who feels they can provide me with these tips. It's appreciated. :-)

16th Jul 2018, 12:47 AM
Mathew McRae
Mathew McRae - avatar
5 Answers
+ 4
Mathew McRae That use of quotation marks is used in inline CSS only and not in external CSS. Inline CSS is considered as an attribute of an element, therefore, it has to be in the format: name="value". That also means that the semicolon in inline CSS should be inside of the quotation marks because it is part of CSS. Example: <p style="color:blue;">
16th Jul 2018, 1:55 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
1. In CSS you can quote just for safety reasons, especially when the values for the rules contains spaces. 2. Inside. The semi-colon should be placed after the value of the rule. It can be omitted, if the rule is only one.
16th Jul 2018, 2:01 AM
Boris Batinkov
Boris Batinkov - avatar
0
Thanks Jonathan & Boris. Jonathan, you mentioned that I should use quotation marks for inline CSS and not external, which is what I thought, but what about internal CSS styling (in the <head> section)? A question to both of you (and everyone else), regarding the semicolon being omitted if there's only one rule, I presume it's still okay to use it when there is only one rule, to be safe? I'm just a perfectionist and I like to do things properly, to the nearest detail. Thanks again, guys.
16th Jul 2018, 3:56 AM
Mathew McRae
Mathew McRae - avatar
0
1. For inline styling You have to use quotation mark as it is attribute to html tag and in html attribute are written in attribute name = "value" pair. 2. For external and internal styling They are similar , you have to write selector and inside curly braces you have to write property and value (dont have to use quotation mark as it isnt attribute). 3. If there is only one property in any styling you can skip semi-colon because semi-colon are used to separate property.Also you can skip semi-colon for last property. Example : <h1 style="color:lightblue; background-color:yellow">Help</h1> Hope this helpsâ˜șâ˜ș.
16th Jul 2018, 7:42 AM
Meet Mehta
Meet Mehta - avatar
0
Thanks Meet Mehta, you were definitely helpful!
16th Jul 2018, 11:54 AM
Mathew McRae
Mathew McRae - avatar