"; 2. Use the style tag to write the css code in the head tag of the document. Syntax ""."/> "; 2. Use the style tag to write the css code in the head tag of the document. Syntax "".">
Home >Web Front-end >CSS Tutorial >Where can css code be placed in html
The location of the css code: 1. Directly use the style attribute and put it in the html tag, with the syntax "36643f942ea2f34798a5b9cbba7e26c6"; 2. Use the style tag to write the css code together In the head tag of the document, the syntax is "c9ccee2e6ea535a969eb3f532ad9fe89css code531ac245ce3e4fe3d50054a55f265927".
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
Basic syntax The format is as follows:
<element style="value">
In the syntax, style
is the attribute of the tag. In fact, any HTML tag has the style
attribute, which is used to set the inline style. The writing specifications of attributes and values are the same as CSS style rules. Inline style only affects the tag where it is located and the subtags nested in it.
It is recommended not to use inline CSS because each HTML tag needs to be styled separately. If you only use inline CSS, it may become very difficult to manage the website. However, it can be useful in certain situations. For example, in situations where you don't have access to CSS files or only need to apply styles to a single element. An example of an HTML page with inline CSS is as follows:
Hostinger Tutorials
Something useful here.
2. Use the style tag to write the css code together In the head tag of an HTML document, the basic syntax format of
is as follows: In the syntax of
<head> <style type="text/css"> css代码 </style> </head>
, the style
tag is generally located in head
After the title
tag in the tag, you can also place it anywhere in the HTML document.
style 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.
Example:
<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>
Extended knowledge:
html’s full name is Hypertext Markup Language, which is a markup language that includes a series of labels. These tags can unify the document formats on the network and connect scattered Internet resources into a logical whole. HTML text is descriptive text composed of html commands. HTML commands can describe text, graphics, animations, sounds, tables, and links. etc., mainly used in conjunction with css js to build elegant front-end web pages.
Recommended learning: CSS video tutorial
The above is the detailed content of Where can css code be placed in html. For more information, please follow other related articles on the PHP Chinese website!