#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
HTML Fundamentals

HTML Comments & Colours

HTML comments let you leave notes in your markup that browsers do not display, and HTML colours let you change the colour of text, backgrounds and borders. Both are small topics, but you use them in almost every page you build: comments to explain or temporarily disable sections, colours to give the page its look.

Writing comments

A comment starts with <!-- and ends with -->. Everything in between is ignored when the page renders, and comments can span several lines.

<!-- Site header: logo and main navigation -->
<header>
  <h1 style="color: #1e3a8a;">City Library</h1>
</header>

<!--
<p>Holiday timings banner, hidden until next month</p>
-->

<p style="background-color: rgb(254, 243, 199); color: #78350f;">
  Open Monday to Saturday.
</p>
<p style="color: hsl(142, 70%, 30%);">New arrivals every week.</p>
<p style="border: 2px solid tomato;">Late fees apply after 14 days.</p>

Good comments explain why something exists or mark the start and end of large sections. They are also useful for "commenting out" code while testing, as with the hidden banner above.

Comments are public

A comment is hidden on the page, but it is still sent to the browser. Anyone can press Ctrl+U or open developer tools and read it. Never leave passwords, API keys, internal URLs or rude notes in comments. Also avoid nesting comments: the first --> ends the whole comment, and the rest of the text appears on the page.

Four ways to write a colour

FormatExampleNotes
NametomatoAbout 140 named colours exist; easy to read but limited
Hex#1e3a8aRed, green, blue in pairs from 00 to ff; #fff is a short form
RGBrgb(254, 243, 199)Each channel from 0 to 255; add alpha for transparency
HSLhsl(142, 70%, 30%)Hue angle, saturation, lightness; easy to make lighter or darker shades

Transparency can be added with rgba(0, 0, 0, 0.5), the newer rgb(0 0 0 / 50%), or an eight-digit hex like #00000080.

HSL is often the easiest format for building a palette by hand. Keeping the hue the same and changing only the lightness gives you a matching family of shades for buttons, borders and hover states.

Where colours are applied

Colour is set with CSS properties: color for text, background-color for the area behind content, and border or border-color for edges. In the example they appear in style attributes to keep things simple. In real projects, put them in a stylesheet so a colour change happens in one place. The old <font color> tag and the bgcolor attribute are obsolete and should not be used.

A colour mistake that hurts readers

Light grey text on a white background, or red text on green, may look stylish on your monitor but becomes hard or impossible to read for many people, including those with colour blindness or using a phone in sunlight. Check the contrast of text against its background, and never use colour as the only way to signal something, such as marking required fields only in red.

Summing up

Use comments for notes that help other developers, but keep secrets out of them. Choose hex, RGB or HSL for precise colours, apply them with CSS, and always confirm that text has enough contrast.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course