Thursday, 14 June 2018

Chaudhari Karan

HTML – Comments

    No comments:


HTML – Comments

Hello friends, In this lecture, we will discuss HTML – Comments.
HTML – Comments

Any piece of code is placed between tags is known as comments. The comment is ignored by a web browser. Add comments into  HTML code, especially in complex documents. It is indicated sections of the document, and other notes to looking at the code. Comments help to understand code and increases code readability.

HTML are used tags for comments. So, any content in this tag   is treated as comment and it is ignored by the web browser.

Example:
HTML – Comments

Output:
HTML – Comments

Valid vs Invalid Comments

In comments, you cannot put inside another comment. It is known as invalid comments.

Second, you cannot use spaces in start comments string like < !--.. -->. This is also invalid comments. So make sure for valid comment does not use spaces in the start-of comment string.

Example

Here, the valid comment example and it will be wiped off by the web browser.

HTML Valid vs Invalid Comments


Here, the invalid comment example and it will be displayed by the web browser. There is a space between the left angle bracket and the exclamation mark.

HTML Valid vs Invalid Comments

Multiline Comments

In above examples, we have seen single line comments, but HTML also supports multi-line comments.

Multiple lines comment also beginning with a tag . In this tag place multiline of comments as shown in the example.

Example:
HTML Multiline Comments

Conditional Comments

Conditional comments only support by Internet Explorer IE on Windows. It is ignored by other web browsers. You can give conditional instructions to different versions of IE.

Example:
HTML Conditional Comments



Using Comment Tag

Internet Explorer browsers support tag to comment the part of HTML code.

Note − The tag is not used in HTML5.

Example:
HTML Using Comment Tag

Commenting Script Code

Through JavaScript and HTML code is recommended to put that script code inside the HTML comments.

Example:

HTML Commenting Script Code
Output:
HTML Commenting Script Code

Commenting Style Sheets

Cascading Style Sheet CSS used in HTML comments as shown in the example.

Example:
HTML Commenting Style Sheets


Output:
HTML Commenting Style Sheets

Subscribe to this Blog via Email :