A brief discussion on the difference between src and href in HTML

A brief discussion on the difference between src and href in HTML

Simply put, src means "I want to load this resource", and href means "I want to associate with this resource"

src is mainly used for element replacement, and href is used to establish relevant links with related documents and external resources.

The href attribute indicates that a link is established between the local web resource and the defined resource.

like:

<link href="style.css" rel="stylesheet"/>

The browser knows that this resource is a style sheet and will not stop parsing when it reaches this element, but rendering the page may stop because the browser needs style rules to render the page.

The browser will not load the CSS file content into the style tag. Therefore we recommend using the link tag instead of @import to load style sheets.

The src attribute will embed the corresponding resource into the current page. like:

<script src="script.js"></script>

When the browser loads and processes the page, it will find script.js and compile the JS. Only then will the subsequent page compilation and parsing work continue.

The JS content will be loaded into the script tag. This is very similar to the img tag. When the browser parses the img tag, it will load the corresponding image and put it into the img tag.

This is why the jS file should be loaded last in the document. Before the label.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  MySQL json format data query operation

>>:  Implementation of Docker container state conversion

Recommend

MySQL Index Optimization Explained

In daily work, we sometimes run slow queries to r...

Solve the cross-domain problem of Vue+SpringBoot+Shiro

Table of contents 1. Configure Vue front end 1. D...

How to use nginx to block a specified interface (URL)

1. Introduction Sometimes, after the web platform...

JavaScript timer to achieve seamless scrolling of pictures

This article shares the specific code of JavaScri...

Markup Languages ​​- What to learn after learning HTML?

Click here to return to the 123WORDPRESS.COM HTML ...

Sample code on how to implement page caching in vue mobile project

background On mobile devices, caching between pag...

VUE+Express+MongoDB front-end and back-end separation to realize a note wall

I plan to realize a series of sticky note walls. ...

Detailed explanation of how to use CMD command to operate MySql database

First: Start and stop the mysql service net stop ...

Detailed explanation of the process of modifying Nginx files in centos7 docker

1. Install nginx in docker: It is very simple to ...

JS Easy to understand Function and Constructor

Table of contents 1. Overview 1.1 Creating a func...

Several ways to center a box in Web development

1. Record several methods of centering the box: 1...

Use Docker to run multiple PHP versions on the server

PHP7 has been out for quite some time, and it is ...

Detailed explanation of Linux dynamic library generation and usage guide

The file name of the dynamic library file under L...