Home > Article > Web Front-end > Where is the css style written?
CSS styles can be written in the following three locations: Inline style: written directly into the style attribute of the HTML element. Internal style sheets: written in the <style> element within the <head> tag. External style sheet: written in a separate .css file and linked to the HTML page through the <link> tag. Generally, the most appropriate location for writing the style is chosen on a case-by-case basis.
CSS style writing location
CSS (Cascading Style Sheets) style is used to control the visual presentation of web pages , it can be written in three positions:
1. Inline style
style
Attributes. <p style="color: red;">This text is red.</p>
2 . Internal style sheet
<style>
element inside the <head>
tag and write the style in it. For example:
<code class="html"><head> <style> p { color: blue; } </style> </head></code>
3. External style sheet
.css
file, the file is linked to the HTML page through the <link>
tag. For example:
<code class="html"><head> <link rel="stylesheet" href="style.css"> </head></code>
Recommended position:
Usually, choose the most appropriate style to write according to the specific situation Insertion position:
<head>
tag. The above is the detailed content of Where is the css style written?. For more information, please follow other related articles on the PHP Chinese website!