There are three ways to reference CSS in HTML: direct inline reference, external reference and embedded reference. Inline references are suitable for small paragraph styles, external references are suitable for global styles, and embedded references are suitable for customizing individual element styles and have the highest priority.
How to reference CSS in HTML
Direct inline reference:
<style>
tag and place it within the <head>
element. Example:
<code class="html"><head> <style> body { background-color: #f0f0f0; } </style> </head></code>
External Reference:
tag in the
<head> element.
<code class="html"><head> <link href="style.css" rel="stylesheet"> </head></code>
Embedded quote:
##Place the CSS code in the
Example:<code class="html"><p style="color: red;">你好,世界!</p></code>
Specific use:
Inline quotation:
Embedded references have the highest priority, followed by inline references, and finally external references.
The above is the detailed content of How to reference css in html. For more information, please follow other related articles on the PHP Chinese website!