


The user can freely choose to change the style referenced by the element, and the imported style sheet will be automatically integrated with the remaining style sheets.
4 ways to combine CSS with HTML documents:
1 Use the element to link to an external style file
2 Use the "style" element in the
3 Use the CSS "@import" tag to import the style sheet
4 Inside the Use the "style" attribute in the element to define the style
An example:
The first is to write css directly on the html page, while the second and third are to use external Reference styles extract files individually.
Question 1. What is the difference between link and @import?
Let’s take a look at their definitions first
link element
Both HTML and XHTML have a structure that allows web page authors to add additional information related to HTML documents. These additional resources can be styled information (CSS), navigation aids, information in other forms (RSS), contact information, etc.
@import
Specify the imported external style sheet and target device type.
In fact, the most fundamental difference between link and @import is that link is a tag in html, and @import is a tag in css.
In addition to calling css, link can also have other functions, such as declaring page link attributes, declaring directories, and rss Wait, and @import can only call css. If you reference css from the outside alone, their functions are basically the same, except that the boss above is different. :)
As mentioned above, because the bosses above are different, there will be some detailed differences in use. I cannot say who is better and who is worse in general.
I can only analyze the specific situation.
1) I want to use javascript for style selection;
This time I need to use link, because link is an html element, and javascript can be used to control the dom element to finally achieve the effect of changing the style.
Look at the following code
Let’s first take a look at what each attribute in link means:
[1]rel: used to declare the role or type of the link object.
For example, in the above code: "stylesheet" means linking to a default css, while "alternate stylesheet" means linking to an alternative css.
[2]href: I don't need to say this, it refers to the file path of the css.
[3]style: file type
[4]media: application device, "screen" means the application is on the screen.
[5]title: is the name of css.
There are a total of 5 css in this code. The first one is the basic style, and the other four are style styles. Use javascript to control the default displayed style title.
The printing style, as the name suggests, is the style when printing the page.
This style has no effect under normal browsing and only takes effect when printing.
If you want to reference the printing style separately for the page, both link and @import can be used.
There is also another way for css @media: @media print {
@import "print.css"
}
Use @media First set the device to print, and then use @impor to link
If you want to reference multiple style combinations on one page to produce effects, both link and @import are also acceptable.
T @Import code & lt; style type = "text/css" & gt; @import url (../ css/base/my.Layout.css); .Typo.css);
& lt;/style & gt;
... is more clearer when referenceing multiple files with @import.
First use link to reference a css file
and then reference it in this css file.
The best way to write @import: There are generally the following ways to write @import:
@import 'style.css' //Windows IE4/ NS4, Mac OS X IE5, Macintosh IE4/IE5/NS4 does not recognize
@import " style.css" //Windows IE4/ NS4, Macintosh IE4/NS4 does not recognize
@import url(style.css) //Windows NS4, Macintosh NS4 does not recognize
@import url('style.css') //Windows NS4 , Mac OS Import url("style.css") is the best choice and is compatible with the most browsers. From the perspective of byte optimization, @import url(style.css) is worthy of being the most recommended writing method.
When writing CSS style sheets, in order to make it easier to read the style definition code later, we will write each code on one line. But I found that writing this way seems not good, because CSS code is not as logical as program code after all. It is mainly written in the corresponding way of name and value. So writing on the same line will not particularly affect reading. On the contrary, it will reduce the size of the style sheet file because many newline characters and spacers are reduced. I tested it and found that the file size can be reduced by about 12%. If the style sheet file is relatively large or there are many files, the download volume of the client will be significantly reduced and the opening speed of the web page will be improved.
Please note that there is no space between the colon of the style name and the following value. Just separate the two styles with a space.
The specific format is as follows:
Program code:
div {margin:20px; padding:10px; background-color:#F00;}

Here's a container with some child elements:

Flyout menus! The second you need to implement a menu that uses a hover event to display more menu items, you're in tricky territory. For one, they should

"The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."- Tim Berners-Lee

In this week's roundup: datepickers are giving keyboard users headaches, a new web component compiler that helps fight FOUC, we finally get our hands on styling list item markers, and four steps to getting webmentions on your site.

The short answer: flex-shrink and flex-basis are probably what you’re lookin’ for.

In this week's look around the world of web platform news, Google Search Console makes it easier to view crawled markup, we learn that custom properties

The IndieWeb is a thing! They've got a conference coming up and everything. The New Yorker is even writing about 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

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

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

Dreamweaver CS6
Visual web development tools