Home > Article > Development Tools > How does webstorm associate css with html?
There are three ways to associate CSS to HTML: inline styles (written directly in HTML), internal style sheets (created within the HTML document), or external style sheets (in separate .css files) stored and referenced in HTML). It is recommended to use external style sheets first to improve style reusability, maintainability and loading speed.
How to associate CSS to HTML
To associate CSS to HTML, there are several methods:
1. Inline style
Write CSS directly in the HTML element:
<code class="html"><p style="color: red;">我的文本</p></code>
2. Internal style sheet
Create a <style>
element in the <head>
section of the HTML document and include the CSS rule within it:
<code class="html"><head> <style> p { color: red; } </style> </head></code>
3. External style sheets
Store CSS rules in a separate .css file, and then reference the file in the HTML document using the <link>
tag:
<code class="html"><head> <link rel="stylesheet" href="mystyle.css"> </head></code>
Benefits of using external style sheets:
Tip:
The above is the detailed content of How does webstorm associate css with html?. For more information, please follow other related articles on the PHP Chinese website!