Now is an era that advocates structure, performance, and behavior separation. The biggest benefit is that it is easy to maintain and convenient,CodeReuse. Writing CSS and Js in HTML is like a hodgedge, which is hard to understand, has poor readability, large files, and is very difficult to maintain.
But is CSS inline or external? As long as we analyze its characteristics, it is not difficult to come up with an answer.
CSS inline:CSS is placed in the HTML head and surrounded by style. <Style type = "text/CSS"> </style>
CSS outreach:Put CSS in a separate file and call it in HTML. <LINK rel = "stylesheet" type = "text/CSS" href = "">.
We know that HTTP requests are expensive, and CSS inline operations will certainly be faster, because placing CSS in an HTML file means reducing an HTTP request. The external connection is an HTTP request, but it can be cached. When the browser loads the file, the second request is read in the cache, therefore, the second request is very fast, and the CSS of the external application can reuse the code. So is inline or external connection used? This depends on the requirement. If a page does not need to be cached, that is, this page is not very accessed, or when there are not many visits, such as the registration page, people usually only enter the page once, it is impossible for you to register the website for the first time. In other words, this page does not need to be cached. If you put CSS in the head, loading time can be shortened and user experience can be improved. For frequently accessed pages, external access is definitely the best choice.
On some large websites, such as Google and Yahoo, you can also see that CSS is written in the head. For the principle of separation of structure and behavior, we can accept CSS input in the head, as long as it is not written on the element.