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

Implementation of waterfall layout + dynamic rendering

Table of contents Typical waterfall website Water...

5 commonly used objects in JavaScript

Table of contents 1. JavaScript Objects 1).Array ...

React's component collaborative use implementation

Table of contents Nesting Parent-child component ...

Example of how to generate random numbers and concatenate strings in MySQL

This article uses an example to describe how MySQ...

WeChat applet date and time component (year, month, day, hour, and minute)

This article example shares the specific code of ...

The process of quickly converting mysql left join to inner join

During the daily optimization process, I found a ...

Alibaba Cloud applies for a free SSL certificate (https) from Cloud Shield

Because the project needs to use https service, I...

HTML table_Powernode Java Academy

To draw a table in HTML, use the table tag tr me...

Detailed tutorial on distributed operation of jmeter in docker environment

1. Build the basic image of jmeter The Dockerfile...

Native Js implementation of calendar widget

This article example shares the specific code of ...

Complete steps to implement face recognition login in Ubuntu

1. Install Howdy: howdy project address sudo add-...

How to hide a certain text in HTML?

Text hiding code, hide a certain text in HTML Copy...

JavaScript operation elements teach you how to change the page content style

Table of contents 1. Operation elements 1.1. Chan...