In HTML, CSS code can directly use the style attribute and put it in the HTML tag. The syntax is "
content "; You can also use the style tag to write the css code in the head tag of the HTML document.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In html, the placement position of css code
##1. Directly use the style attribute and place it in the html tag
The basic syntax format is as follows:<标签名 style="属性名1:属性值1;属性名2:属性值2;属性名3:属性值3;...."> 内容</标签名>
<!DOCTYPE html> <html> <body style="background-color:black;"> <h1 style="color:white;padding:30px;">Hostinger Tutorials</h1> <p style="color:white;">Something usefull here.</p> </body> </html>
2. Use the style tag to write the css code in the head tag of the HTML document
The basic syntax format is as follows:<head> <style type="text/CSS"> 选择器 {属性名1:属性值1;属性名2:属性值2;属性名3:属性值3;....} </style> </head>
type="text/CSS" can be omitted in HTML5, and it is more in line with the specifications, so this place can be written or omitted.
<head> <style type="text/css"> p {color:white; font-size: 10px;} .center {display: block; margin: 0 auto;} #button-go, #button-back {border: solid 1px black;} </style> </head>
css video tutorial)
The above is the detailed content of Where to put css code in html. For more information, please follow other related articles on the PHP Chinese website!