新增了一个分类,叫做 Personals,中文我把它解释成 "个人恶趣味",这里将记载一些对工作无关紧要,但是个人又一时有兴趣了解的东西。
今天要讲的是如题的 4 种扩展文件的区别。和大多数人一样,我首先接触到的也是 .html 后缀的文件,后来在工作中发现前端写的都是 .htm 后缀的文件,再后来接触到了 .shtml 的扩展文件,与它相应的还有 .shtm 的文件。遂花了一点时间了解了下它们之间的区别,记录如下。
.htm VS .html
首先来看 .htm 和 .html 文件的区别。答案居然是: 它们是相同的。
事实上,这只是个人喜好问题,保持统一的后缀名即可。习惯上,windows 通常会用 .htm 的后缀名,而 linux(unix) 会用 .html 后缀(在 linux 中,如果打开 .htm 的文件,会直接展示源码)。这是因为很久以前,操作系统(DOS)的平台是 window 3.x.x,系统对于文件有个 8.3约束(8.3 naming convention),即文件名只能是 8 个字符,后缀只能是 3 个字符,所以当时显然无法使用 .html 后缀。而现在,这些问题都已经不复存在了。(个人感觉 .html 更正规一点,一些人认为使用 .htm 是回到了 dos 时代)
还有个问题是服务端的,如果服务端某文件夹下同时有 index.html 和 index.htm 文件,URL 省略了后面的文件名(如 http://www.domain.dom/dirname/),那么显然一个文件会优先于另一文件被读取(先解析 index.html)。事实上,我们一般不会在同一个文件夹下保存两个 index 文件。
.html VS .shtml
接着来说说 .html 和 .shtml 文件的区别,简单说 .shtml 文件就是 html 文件加个 ssi。那么,ssi 又是什么鬼?其实这玩意儿之前已经接触过,在 Apache下开启SSI配置使html支持include包含一文中。
SSI 是 Server Side Include 的首字母缩略词。包含有嵌入式服务器方包含命令的 HTML 文本。在被传送给浏览器之前,服务器会对 SHTML 文档进行完全地读取、分析以及修改。SSI 就是在 HTML 文件中,可以通过注释行调用的命令或指针。SSI 具有强大的功能,只要使用一条简单的 SSI 命令就可以实现整个网站的内容更新,时间和日期的动态显示,以及执行 shell 和 CGI 脚本程序等复杂的功能。 网站维护常常碰到的一个问题是,网站的结构已经固定,却为了更新一点内容而不得不重做一大批网页。SSI 提供了一种简单、有效的方法来解决这一问题,它将一个网站的基本结构放在几个简单的 HTML 文件中(模板),以后我们要做的只是将文本传到服务器,让程序按照模板自动生成网页,从而使管理大型网站变得容易。
应用它可以把网站中一些公共区域做成独立的页面,然后利用此技术嵌入到其它需要此区域内容的页面中去。
机制:
SSI 机制是 动态包含,而不是静态生成,是由 web服务器比如 apache 在收到用户的请求时,如果解析到其中有 SSI 包含指令时,自动取出被包含的页面嵌入到被请求的页面中一起当做一个整体的页面发送给用户,对用户来说根本不知道服务器做了啥,只是知道得到一个完整的页面。
由 SSI 工作机制我们知道,包含动作是在每次用户请求页面时发生,所以如果被包含的页面内容有变化,也能实时的反应出来,正因为如此,就很容易用来实现静态页面的动态嵌入,我们就可以用来实现网站中全站公共区域,或是 出现很多的重复区域内容发布成一个独立静态页面,然后在需要的地方用SSI指令包含进去, 比如像全站的头部和尾部,全站最新新闻等等。
事实上,.html 的文件同样可以开启 SSI,只需在 apache 里进行相应的配置,一旦开启 SSI,.html 文件和 .shtml 文件可以一样对待了。
AddType text/html .shtml .htmlAddOutputFilter INCLUDES .shtml .html
具体配置方法可以参考 Apache下开启SSI配置使html支持include包含
至于 .shtm 文件,window7 apache 下直接在浏览器中打开了源码。

Boolean attributes are special attributes in HTML that are activated without a value. 1. The Boolean attribute controls the behavior of the element by whether it exists or not, such as disabled disable the input box. 2.Their working principle is to change element behavior according to the existence of attributes when the browser parses. 3. The basic usage is to directly add attributes, and the advanced usage can be dynamically controlled through JavaScript. 4. Common mistakes are mistakenly thinking that values need to be set, and the correct writing method should be concise. 5. The best practice is to keep the code concise and use Boolean properties reasonably to optimize web page performance and user experience.

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

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.

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

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.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.


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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor
