Why not use img tag to control image size in html?
A customer once told me that he uploaded news pictures in the background of the website. They were taken by a camera. However, they were uploaded but exceeded the display range of the web page. A scroll bar appeared. He asked me how to deal with it. I told him to use image processing first. The software processes the image to a suitable size and then uploads it, such as processing it into a width of 600 pixels, and scaling the height proportionally. He told me that previous websites did not need to process images, and the size would be the same when uploaded, so this would not happen. After some explanation, he understood the benefits of doing so.
When using div and css to create the template for the website content page, we will fix the style of some of the content, such as the size and color of the title, and the release time. Fonts, colors, etc., of course, there are pictures in the content page. These pictures are uploaded to the server through the corresponding website content management system, and are referenced in the content page using the img tag to display on the web page.
The pixels of the pictures taken with the camera generally far exceed the size of the browsing range of the web content area, and the size of the picture itself is also about 1M. Sometimes for convenience, the picture is uploaded directly and then used css. The width of the image is uniformly controlled and the height is automatically adapted. However, this only makes the pixels of the image seen by web viewers become smaller, which seems to be in harmony with the content. In fact, the web page has already loaded this image of about 1M. If a page There are several news pictures, so many 1M-sized pictures must be loaded continuously. At this time, the opening speed of the web page will obviously slow down, and some pictures will have a certain degree of distortion.
In addition, if the size of the image in the content is written down, sometimes when uploading some attachments, there will be a small icon in front of the attachment. Since this small icon is also introduced using the img tag, it will also be " "Enlarge", to solve this problem, you must modify the style of this icon separately, which is very troublesome, and general content update personnel often do not understand these technical tasks.
When the website is revised, the original company may not be responsible, and if the pictures uploaded to the server have not been processed, the problem of "slow picture loading" will still not be solved, because It is impossible for the person responsible for revision to process all your images one by one.
There are many effects that can be achieved technically, but not all solutions are reasonable. Therefore, as website construction technicians, we must develop the habit of processing images first and then uploading them. That is, how many pixels are needed to display the web page are processed in advance and then uploaded. This not only saves disk space, but also increases the speed at which viewers open the page.
The above is the detailed content of Why not use img tag to control image size in html?. For more information, please follow other related articles on the PHP Chinese website!

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

Do you want to know how to display child categories on the parent category archive page? When you customize a classification archive page, you may need to do this to make it more useful to your visitors. In this article, we will show you how to easily display child categories on the parent category archive page. Why do subcategories appear on parent category archive page? By displaying all child categories on the parent category archive page, you can make them less generic and more useful to visitors. For example, if you run a WordPress blog about books and have a taxonomy called "Theme", you can add sub-taxonomy such as "novel", "non-fiction" so that your readers can

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML5 code consists of tags, elements and attributes: 1. The tag defines the content type and is surrounded by angle brackets, such as. 2. Elements are composed of start tags, contents and end tags, such as contents. 3. Attributes define key-value pairs in the start tag, enhance functions, such as. These are the basic units for building web structure.

In IntelliJ...

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

React operates in HTML via virtual DOM. 1) React uses JSX syntax to write HTML-like structures. 2) Virtual DOM management UI update, efficient rendering through Diffing algorithm. 3) Use ReactDOM.render() to render the component to the real DOM. 4) Optimization and best practices include using React.memo and component splitting to improve performance and maintainability.
