Comment ng CSS

Comment ng CSS

Ang mga komento ay ginagamit upang ipaliwanag ang code, na maaaring maging kapakinabangan sa iyong pagwawasto ng source code sa hinaharap.

Ang mga komento ay aalisin ng browser.

nasa <style> ang CSS komento sa loob ng elemento, na /* magsimula, gamit */ Tapusin:

Example

/* Ito ay isang unang linya komento */
p {
  color: red;
}

Try It Yourself

Maaari mong magdagdag ng komento sa anumang lugar ng iyong code:

Example

p {
  color: red;  /* Gagawing red ang teksto */
}

Try It Yourself

ang komento ay maaaring magkabagtas sa maraming linya:

Example

/* Ito ay
isang maraming-linya
komento */ 
p {
  color: red;
}

Try It Yourself

HTML at CSS komento

Sa tutorial ng HTML, natutuhan mo na maaaring gamitin <!--...--> Syntax Add comments in the HTML source code.

In the following example, we combine the use of HTML and CSS comments:

Example

<!DOCTYPE html>
<html>
<head>
<style>
p {
  color: red; /* Set text color to red */
} 
</style>
</head>
<body>
<h2>My Heading</h2>
<!-- These paragraphs will be red -->
<p>Hello World!</p>
<p>This text is styled by CSS.</p>
<p>CSS Comments Will Not Be Displayed in the Output.</p>
</body>
</html>

Try It Yourself