search
HomeWeb Front-endCSS TutorialHow to optimize HTML web pages

How to optimize HTML web pages

Nov 29, 2017 am 10:26 AM
htmloptimizationWeb page

We know that in HTML, you not only have to make good-looking web pages, but also consider the optimization of web pages. So today I will give you ideas on how to optimize HTML web pages. I have summarized 5 points. Let’s take a look

Change table to div layout

Try to reconstruct the table tag layout html into the div layout, which can save at least 40% of the code. Since the div code is less than the html webpage with table layout, the search engine index weight is also better than the html webpage with table layout. Reduce and streamline div, span, ul li and other series of tags

When laying out DIV+CSS web pages, we can sometimes save some DIV layout code and reduce the amount of code.

The following case code:

<div class="div"> 
  <ul> 
  <li>DIV</li> 
  <li>DIV</li> 
  <li>DIV</li> 
  </ul> 
</div>

can be changed to:

    lass="div"> 
      <li>DIV</li> 
      <li>DIV</li> 
      <li>DIV</li> 
    </ul>

    This can save a pair of div tags, thereby reducing the amount of html code , which plays the role of compressing html. In this way, directly naming the css style class for ul can distinguish the use of ul li list tags in different places on a page.

    Delete

    Excess spaces Delete excess spaces and line breaks, which can effectively compress the bytes occupied by the html code. Generally, after the development is completed, the code in the html can be deleted, line breaks, and line breaks. Space content.

    You can use DW software to batch delete spaces between tags in html

    For example:

    <div class="div"> 
      <div ...></div> 
    </div>

    You can delete spaces and line breaks:

    This can save bytes occupied by spaces and line breaks.

    Note that the published version of the web page can use DW to delete redundant spaces and blank lines. If you want to edit again, go to DW software to format the code.

    Table

    In type layout, use table instead of div layout appropriatelyIf it is a table data list layout, we'd better choose table, because using table for table layout is better than div layout, using table layout saves

    html tag

    code and saves css style than div layout. As shown in the table below

    Data type

    , it is recommended to use TABLE tag + CSS style layouthtml web page code compression table tag layout table

    Similar to this list Table table, it is recommended to use the table tag layout

    Webpage GZIP Compression

    It is recommended to set the webpage Gzip compression function on your own server.

    1. What are the benefits of opening GZIP?

    Answer: After Gzip is turned on, the data output to the user's browser will be compressed, which will reduce the amount of data transmitted through the network and increase the browsing speed.

    2. How to enable the Gzip compression function of IIS:

    Answer: First, if you need to compress static files (HTML), you need to create a directory on the hard disk and give it "IUSR_ Write permissions for the user "Machine Name". If you compress dynamic files (PHP, asp, aspx), there is no need, because its pages are dynamically generated every time and will be given up after compression. Then in the IIS manager, right-click on "Website" - Properties, not a certain site below, but the entire website. Enter the "Services" tab and select Enable dynamic content compression and static content compression. Then select the server extension under the website and create a new server extension. The name doesn't matter, the path to add the file below is: c:\windows\system32\inetsrv\gzip.dll, and then enable this extension. At this time, static content can be compressed, but for dynamic content, aspx files are not within the compression range. Because the default compressible file does not have this extension. And you can't find a place to add an extension in the management interface. At this time, you can only modify its

    config file

    . There is a MetaBase.xml file under c:\windows\system32\inetsrv\. You can open it with Notepad and find IIsCompressionScheme. There are three sections with the same name, namely deflate, gzip, and Parameters. Don’t worry about the third section. The two paragraphs have basically the same parameters. Add a line of aspx below the parameter HcScriptFileExtensions in these two paragraphs. If you have other dynamic programs to compress, add them here. HcDynamicCompressionLevel is changed to 9, (0-10, 9 is the most cost-effective one). Then you need to restart the IIS service to experience the speed after compression. I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website!


    Related reading:

    Implementation steps of Js operating window object


    Js operates non-IE event object properties, detailed introduction of the method


    Use DIV and CSS to make a red box with a solid border

The above is the detailed content of How to optimize HTML web pages. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Lost CSS Tricks of Cohost.orgThe Lost CSS Tricks of Cohost.orgApr 25, 2025 am 09:51 AM

In this post, Blackle Mori shows you a few of the hacks found while trying to push the limits of Cohost’s HTML support. Use these if you dare, lest you too get labelled a CSS criminal.

Next Level CSS Styling for CursorsNext Level CSS Styling for CursorsApr 23, 2025 am 11:04 AM

Custom cursors with CSS are great, but we can take things to the next level with JavaScript. Using JavaScript, we can transition between cursor states, place dynamic text within the cursor, apply complex animations, and apply filters.

Worlds Collide: Keyframe Collision Detection Using Style QueriesWorlds Collide: Keyframe Collision Detection Using Style QueriesApr 23, 2025 am 10:42 AM

Interactive CSS animations with elements ricocheting off each other seem more plausible in 2025. While it’s unnecessary to implement Pong in CSS, the increasing flexibility and power of CSS reinforce Lee's suspicion that one day it will be a

Using CSS backdrop-filter for UI EffectsUsing CSS backdrop-filter for UI EffectsApr 23, 2025 am 10:20 AM

Tips and tricks on utilizing the CSS backdrop-filter property to style user interfaces. You’ll learn how to layer backdrop filters among multiple elements, and integrate them with other CSS graphical effects to create elaborate designs.

SMIL on?SMIL on?Apr 23, 2025 am 09:57 AM

Well, it turns out that SVG's built-in animation features were never deprecated as planned. Sure, CSS and JavaScript are more than capable of carrying the load, but it's good to know that SMIL is not dead in the water as previously

'Pretty' is in the eye of the beholder'Pretty' is in the eye of the beholderApr 23, 2025 am 09:40 AM

Yay, let's jump for text-wrap: pretty landing in Safari Technology Preview! But beware that it's different from how it works in Chromium browsers.

CSS-Tricks Chronicles XLIIICSS-Tricks Chronicles XLIIIApr 23, 2025 am 09:35 AM

This CSS-Tricks update highlights significant progress in the Almanac, recent podcast appearances, a new CSS counters guide, and the addition of several new authors contributing valuable content.

Tailwind's @apply Feature is Better Than it SoundsTailwind's @apply Feature is Better Than it SoundsApr 23, 2025 am 09:23 AM

Most of the time, people showcase Tailwind's @apply feature with one of Tailwind's single-property utilities (which changes a single CSS declaration). When showcased this way, @apply doesn't sound promising at all. So obvio

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

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.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

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),

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools