A simple example of how to use the three methods is as follows:
Inline style:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>css行内样式</title> </head> <body> <div style="width:100px;height:100px;background:red;"></div>> </body> </html>
(Recommended tutorial: CSS tutorial )
Inline style:
<!!doctype html> <html> <head> <meta charset="UTF-8"> <title>css内嵌样式</title> </head> <body> <style type="text/css"> #div{width:100px;height:100px;background:red;} </style> <div id="div"></div>> </body> </html>
External style:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>css内嵌样式</title> <link rel="stylesheet" type="text/css" href="ccss.css"> </head> <body> <div id="div"></div>> </body> </html>
css file:
#div{width:100px;height:100px;background:red;}
Summary:
Inline style: The code is written within an element in a specific web page; for example:
Inline style: It is within < ;/head>Write in front; for example:
External style: refers to an external css file; for example :
Related video tutorial recommendations: css video tutorial
The above is the detailed content of Detailed explanation of how to use CSS inline styles, embedded styles and external reference styles. For more information, please follow other related articles on the PHP Chinese website!