Methods to introduce css files: 1. Inline method introduction, set the CSS style in the style attribute of the tag; 2. Embedded method introduction, write the CSS style in the style tag of the web page; 3 , Use link to reference external CSS files; 4. Use @import to reference external CSS files.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
How to import css files? Several methods of introducing CSS files into HTML
Generally speaking, there are four types:
1. Inline style: also called inline style, set in the style attribute of the mark Define CSS styles. This method does not reflect the advantages of CSS;
2. Embedded: Concentrate the CSS styles on the
tag pair of the web page's Tags are aligned;3. Link type: The fourth import type is called external type or external link type, use link to refer to external CSS files;
4. Import type: use @import refers to external CSS files;
---------------------------------------- ----------------A
Inline style is the easiest and most comfortable way to start writing, but this way of writing does not reflect the advantages of CSS at all. As follows:
If there are many tags on a page, this writing method will look bad and cumbersome, and it will be too repetitive, so it is not recommended!
-------------------------------------------------- ---------B
Embedded is also a good choice if there are relatively few pages, but if there are many pages corresponding to a project, this will undoubtedly be a bit disastrous. You need to modify the style. It may be a large number of similar pages
, but they have to be modified one by one, as follows:
<span style="font-size:14px;"><style type="text/css"></span> <span style="font-size:14px;">#demo{ position:absoulte; left: 20px; top:50px; width:300px; height: 50px; border: solid 1px red; padding-left: 20px; color:gray; font-size: 20px; line-height: 50px; text-align: center;</span> <span style="font-size:14px;">} </style></span>
This writing method avoids the "no style" phenomenon of the page to a certain extent. Render the page after the css is loaded...
--------------------------------- --------------------CD
External css style is to write the css code in a separate external file. This css style file ends with ". css" as the extension, use the tag within the
tag (not within the , but in css files, you can directly @importis used to add the path. This brings up a point: for projects with many style files, we can choose to render the main styles first, and some secondary ones. Import it in the css file
, which can also alleviate the pressure on the server to a certain extent. Although the file is not large, it is still good to optimize it. In essence, there is not much difference between these two external introduction methods, but sometimes for the convenience of editing the style of the site in the project, the link method is often used.
Of course there are some introduction methods that use XML as editing requirements, but they are not commonly used....
Recommended learning: "
css Video TutorialThe above is the detailed content of How to import css files. For more information, please follow other related articles on the PHP Chinese website!

What it looks like to troubleshoot one of those impossible issues that turns out to be something totally else you never thought of.

@keyframesandCSSTransitionsdifferincomplexity:@keyframesallowsfordetailedanimationsequences,whileCSSTransitionshandlesimplestatechanges.UseCSSTransitionsforhovereffectslikebuttoncolorchanges,and@keyframesforintricateanimationslikerotatingspinners.

I know, I know: there are a ton of content management system options available, and while I've tested several, none have really been the one, y'know? Weird pricing models, difficult customization, some even end up becoming a whole &

Linking CSS files to HTML can be achieved by using elements in part of HTML. 1) Use tags to link local CSS files. 2) Multiple CSS files can be implemented by adding multiple tags. 3) External CSS files use absolute URL links, such as. 4) Ensure the correct use of file paths and CSS file loading order, and optimize performance can use CSS preprocessor to merge files.

Choosing Flexbox or Grid depends on the layout requirements: 1) Flexbox is suitable for one-dimensional layouts, such as navigation bar; 2) Grid is suitable for two-dimensional layouts, such as magazine layouts. The two can be used in the project to improve the layout effect.

The best way to include CSS files is to use tags to introduce external CSS files in the HTML part. 1. Use tags to introduce external CSS files, such as. 2. For small adjustments, inline CSS can be used, but should be used with caution. 3. Large projects can use CSS preprocessors such as Sass or Less to import other CSS files through @import. 4. For performance, CSS files should be merged and CDN should be used, and compressed using tools such as CSSNano.

Yes,youshouldlearnbothFlexboxandGrid.1)Flexboxisidealforone-dimensional,flexiblelayoutslikenavigationmenus.2)Gridexcelsintwo-dimensional,complexdesignssuchasmagazinelayouts.3)Combiningbothenhanceslayoutflexibilityandresponsiveness,allowingforstructur

What does it look like to refactor your own code? John Rhea picks apart an old CSS animation he wrote and walks through the thought process of optimizing it.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
