Home Web Front-end HTML Tutorial How to comment html, css, js code? Summary of usage of html, css, and js comments

How to comment html, css, js code? Summary of usage of html, css, and js comments

Jun 05, 2017 am 10:24 AM

Comment tags are supported in all browsers.

The comment tag is used to insert comments in the source code. Comments will not be displayed in the browser.

You can use comments to explain your code, which will help you edit the code at a later time. Especially useful when you write a lot of code.

It is also a good habit to use comment tags to hide scripts that are not supported by the browser (so that the script will not be displayed as plain text). How to comment the html, css, and js codes specifically? The following is a summary of usage examples of html, css, and js comments!

How to comment html, css, js code? Summary of usage of html, css, and js comments

1. Understand html, css, js comments

1. Html commentsHtml Introduction to the symbols for marking text comments in Html

In this article, let’s learn about the symbols for marking text comments in Html

HTML comments, we often have to make some HTML next to some code Note, there are many benefits to doing this, such as: it is convenient to search, it is convenient to compare, it is convenient for other programmers in the project team to understand your code, and it is also convenient for you to understand and modify your own code in the future, etc.

Start using

2. Conditional comments in HTML

Previous words

IE conditional comment is a non-standard logical statement provided by Microsoft since IE5. Its function is to flexibly import different html elements for different IE versions of browsers. Obviously, the biggest advantage of this method is that it is a compatible solution officially given by Microsoft and can also identify IE

through W3C verification

Because starting from IE10, the IE browser no longer Conditional comments are now supported. Therefore, the following writing method can only recognize IE9-browser

[Note] There must be no space between the two -- and the left bracket [, otherwise it will be invalid

3. Share An example of how Translater.JS cleverly uses HTML comments to translate pages

Follow JSDigs to give you something to do occasionally.

This is a page translation solution that utilizes HTML comments. For a small number of static pages, this solution appears simpler. It has no dependencies and is only compressed (~2kb).

2. Specific usage examples of html, css, and js comments

1. Introduction to some advanced usage of CSS comments

Quasi-qualified selectors

You should avoid over-qualified selectors. For example, if you can write .nav{}, try not to write ul.nav{ }. Excessive modification of selectors will affect performance, affect class reusability, and increase selector privacy. These are things you should try to avoid.

But sometimes you may want to tell other developers the scope of use of a class. Taking .product-page as an example, this class looks like a root container, which may be an html or body element, but it cannot be determined based on .product-page alone.

2. Standard usage of html, css and js comments

Add necessary comments, a good habit that a responsible and ethical front-end must have , which can greatly improve the maintainability and readability of the code. The editor below will introduce to you a summary of the standard usage of html, css and js comments. Friends who need it can refer to it

3. HTML comments - learn HTML+CSS at your fingertips

What are code comments? The function of code comments is to help programmers mark the purpose of the code. If you look at the code you wrote after a while, you can quickly remember the purpose of this code. Code comments not only make it easier for programmers to recall the purpose of previous code, but also help other programmers quickly understand the functions of your program, making it easier for multiple people to collaborate on developing web page code.

3. Related questions and answers

1. What is the shortcut key for adding comments in CSS?

2. javascript - How to use nodeType information to write a function to get all HTML comments in the area

[Related recommendations]

1. html comments

2. C# Example of method to remove comments based on regular expression

3. View java source code and detailed introduction of comment method

The above is the detailed content of How to comment html, css, js code? Summary of usage of html, css, and js comments. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

React's Role in HTML: Enhancing User Experience React's Role in HTML: Enhancing User Experience Apr 09, 2025 am 12:11 AM

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

See all articles