Home > Article > Web Front-end > Can css be written in html?
css can be written in HTML. The writing methods are: 1. Write css in the style tag of the head tag; 2. Add the style attribute directly to the HTML code, and then define the css code in the attribute. .
The operating environment of this tutorial: windows7 system, css3&&html5 version, Dell G3 computer.
Recommended: "css video tutorial" "HTML video tutorial"
How to write css in HTML:
1. Internal style sheet - write css in the style tag of the head tag
When a single file requires special styles, you can use the internal style sheet. You can define internal style sheets via the c9ccee2e6ea535a969eb3f532ad9fe89 tag in the head section.
<head> <style type="text/css"> body {background-color: red} p {margin-left: 20px} </style> </head>
c9ccee2e6ea535a969eb3f532ad9fe89 tag is used to define style information for HTML documents.
In style, you can specify how the HTML document is rendered in the browser.
The type attribute is required and defines the content of the style element. The only possible value is "text/css". The
style element is located in the head section.
2. Inline style - add the style attribute directly to the HTML code, and then define the css code in the attribute.
When special styles need to be applied to individual elements, you can use inline styles. couplet style. The way to use inline styles is to use the style attribute in the relevant tag. Style properties can contain any CSS property. The following example shows how to change the color and left margin of a paragraph.
<p style="color: red; margin-left: 20px"> This is a paragraph </p>
The above is the detailed content of Can css be written in html?. For more information, please follow other related articles on the PHP Chinese website!