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 trialIan Johnson
2,749 PointsDoes the method for including comments differ between .HTML and .CSS formatting?
I'm sure Joy stated comments are written as <!-- blah blah blah --> in a previous vid [I wrote this in my notes], but they look to be written as /****** blah blah blah ******/ in CSS sheets?
Are comments set up differently between the two formats?
3 Answers
jb30
44,807 PointsYes, the comments are formatted differently.
<!-- This is a comment in html. -->
/* This is not a comment in html and will be treated as text. */
/* This is a comment in css. */
<!-- This is not a comment in css and no css past this point will be interpreted. -->
Ian Johnson
2,749 PointsOh, that's interesting - you don't have to define text with any tags to include it in the document... and it can go anywhere in the document (i.e. before/after <html>/<body>/etc. tags)?
Further daft question; am I right in thinking the '< >' bits that define sections of the html document are referred to as 'tags', but once filled out with some form of definition/content (e.g. <head>/<body>/etc.) it becomes an element? Further to that, attributes (e.g. <lang>/<meta>/etc.) define additional characteristics or properties of the element - similar to how an adjective would describe/modify a noun?
I'm struggling to wrap my head around some of the nomenclature, aha.
Thanks again for the assistance.
jb30
44,807 PointsHTML is very forgiving and tries to make sense of your input even if it isn't in the correct format. You can output text without tags in most places of the document. One exception is when you place your text between <
and >
of a tag, where it is interpreted as attributes. However, it is not recommended to output the text without using tags.
<head>
, <body>
, <p>
and </p>
would be tags. <p>This entire code block is an element.</p>
is an element, including its tags and the content between them.
Your ideas about what attributes do is correct. lang
is an attribute, and is placed within a tag such as <html lang="en">
, but isn't used as a tag by itself. <meta>
is a tag rather than an attribute, and attributes such as charset
are added in its tag: <meta charset="utf-8">
.
Ian Johnson
2,749 PointsThank you very much, @jb30.