DEV Community

Cover image for Comment a line in HTML
CoderLegion
CoderLegion

Posted on • Edited on • Originally published at kodblems.com

1 1

Comment a line in HTML

🎉 Before you dive into this article...

🚀 Check out our vibrant new community at CoderLegion.com!

💡 Share your knowledge, connect with like-minded developers, and grow together.

👉 Click here to join now!

However the syntax was developed by Microsoft to allow the inclusion of conditional code, HTML or CSS. This is what Microsoft calls "Conditional Comments".

And it gets more complicated. They are only recognized by Internet Explorer, since version 5, but since they are used to adapt the code according to the version of Internet Explorer, the fact that they are ignored by other browsers is irrelevant.

Conditional code
By placing code in a conditional comment, it is made accessible or not to the browser rendering engine depending on the condition.

There are two types of conditional comments, those whose content is ignored by browsers that do not interpret the conditional expression, and those whose content on the contrary will always be taken into account.

Comment whose content should be ignored by other browsers
For Internet Explorer, whether the content is taken into account depends on whether the condition is satisfied.

<! - [if expression ]>
HTML

<! [endif] ->
What other browsers see:

<! - [if expression ]>
HTML
<! [endif] ->
Anything between the opening and closing tags is a comment and should be ignored.

Comment whose content must be taken into account by other browsers
In the case of Internet Explorer, the content will be taken into account only if the condition of the expression is met.

<! [if expression ]>
HTML

<! [endif]>
What other browsers see:

<! [if expression ]>

HTML

<! [endif]>

The opening and closing tags are not part of the HTML standard, they are ignored and therefore the content is taken into account.

HTML, JavaScript, CSS
The content can be any HTML code. It can be CSS code introduced by the

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay