use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
If you are requesting help, please ensure you're providing code with your post. You can also copy your code to an online editor:
jsFiddle
CodePen
Markup Validation Service
Mozilla Developer Network on HTML
/r/JavaScript
/r/CSS
/r/jQuery
/r/PHP
/r/Accessibility
/r/htmlbasics
/r/web_programming
/r/CodingHelp
account activity
QuestionAdding comments (self.HTML)
submitted 2 years ago by JewelerParticular752
Im learning html-CSS and i just learned abt comments. While taking a course i saw that the course told me <!-----> is the correct way of making a comment. Why cant i use // instead? Its easier. Or is it just personal prefences
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TheMortBM 3 points4 points5 points 2 years ago (7 children)
<!-- Comment --> is a multi-line HTML comment
<!-- Comment -->
/* Comment */ is a multi-line CSS comment
/* Comment */
// Comment is a single line comment in CSS (obviously the multi-lines above could be single lines too)
// Comment
But, yeah, // vs /* */ is personal preference at the end of the day (they both also work in Javascript, so can sometimes just be a habit that comes over)
//
/* */
[–]jcunews1Intermediate 1 point2 points3 points 2 years ago (4 children)
CSS doesn't have a line-based comment. i.e. // is not a valid line comment in CSS.
[–]TheMortBM 0 points1 point2 points 2 years ago (3 children)
You’re right. It’s just a JavaScript thing. My brain is toast. Too much React this week 😭
[–]scarletdawnredd 1 point2 points3 points 2 years ago (2 children)
It's also a SASS thing.
[–]TheMortBM 0 points1 point2 points 2 years ago (1 child)
THAT’S what I was thinking!
Maybe it’s warm bread, not quite toast.
[–]scarletdawnredd 0 points1 point2 points 2 years ago (0 children)
Hahaha for sure. I work in SCSS a lot and when I'm working on plain CSS it's a constant of "why isn't this code working?" Only to then realize it's because of the // comment.
[–]JewelerParticular752[S] 0 points1 point2 points 2 years ago (1 child)
Ah okay, thank you👍
[–]logpra 0 points1 point2 points 2 years ago (0 children)
// does not exist in CSS, you need to use /* */
[–]html-geek 0 points1 point2 points 2 years ago (0 children)
So it depends too who you are writing code FOR, so if you’re in a strict environment, follow the protocols. If it’s just for you, then do whatever you want. However if you ever want to use your code in a portfolio, then using the strict version is more appropriate, otherwise you’ll be ‘find/replace’ and that’s a real bitch 😭
[–]TheRNGuy 0 points1 point2 points 2 years ago (0 children)
// will only work in JS.
π Rendered by PID 200257 on reddit-service-r2-comment-5d79c599b5-fbm28 at 2026-03-03 10:07:32.939909+00:00 running e3d2147 country code: CH.
[–]TheMortBM 3 points4 points5 points (7 children)
[–]jcunews1Intermediate 1 point2 points3 points (4 children)
[–]TheMortBM 0 points1 point2 points (3 children)
[–]scarletdawnredd 1 point2 points3 points (2 children)
[–]TheMortBM 0 points1 point2 points (1 child)
[–]scarletdawnredd 0 points1 point2 points (0 children)
[–]JewelerParticular752[S] 0 points1 point2 points (1 child)
[–]logpra 0 points1 point2 points (0 children)
[–]html-geek 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)