Detailed explanation of the difference between alt and title

Detailed explanation of the difference between alt and title

These two attributes are often used, but their differences have not been summarized. Now let me summarize their usage:

Similarities: They will both display a small floating layer to display text content.

Differences:

1. alt can only be an attribute of an element, while title can be either an attribute of an element or a tag, for example: <title>Title</title>.

2. The alt attribute is used to specify replacement text and can only be used in img, area and input elements (including applet elements). It is used to provide users with text descriptions to help them understand image information when images on a web page cannot be displayed normally. Note that alt is used to replace images rather than provide additional explanatory text. According to some SEO experts, using the alt attribute also has a search engine optimization effect, because search engines cannot directly read image information, and alt can provide them with text information, so it is more friendly to search engines.

The title can be used on any element. When you move the mouse over the element, the content of the title will be displayed to provide additional explanations or prompts.

But, people often make mistakes when using both title and alt attributes in img tags. In older versions of IE browsers, when the mouse passes over an image, the prompt text displayed is the content of the alt attribute, while the title attribute is ignored. This has misled many people. Therefore, if you want to display the content of title in IE, either the title attribute is consistent with alt, or the alt content is empty ("", no spaces are allowed). However, this situation will no longer occur in the new version of IE (IE8 and above).

In addition, when the img tag is nested within the a tag, the title attribute of img takes effect.

The above detailed explanation of the usage differences between alt and title is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

Original URL: http://www.cnblogs.com/freefish12/archive/2016/06/07/5567339.html

<<:  Solution to IDEA not being able to connect to MySQL port number occupation

>>:  JavaScript form validation example

Recommend

Use Docker to build a Redis master-slave replication cluster

In a cluster with master-slave replication mode, ...

A brief discussion on mysql backup and restore for a single table

A. Installation of MySQL backup tool xtrabackup 1...

Example of how to identify the user using a linux Bash script

It is often necessary to run commands with sudo i...

Zabbix implements monitoring of multiple mysql processes

Three MySQL instance processes are started on one...

Detailed explanation of JavaScript array deduplication

Table of contents 1. Array deduplication 2. Dedup...

Detailed explanation of linux crm deployment code

Linux basic configuration Compile and install pyt...

Vue page monitoring user preview time function implementation code

A recent business involves such a requirement tha...

Docker adds a bridge and sets the IP address range

I don't know if it's because the binary d...

Understanding of CSS selector weight (personal test)

Copy code The code is as follows: <style type=...

Solution to the blank page after vue.js packaged project

I believe that many partners who have just come i...

What is Software 404 and 404 Error and what is the difference between them

First of all, what is 404 and soft 404? 404: Simpl...

MySQL 5.7 installation and configuration tutorial under CentOS7 64 bit

Installation environment: CentOS7 64-bit MINI ver...

The difference between GB2312, GBK and UTF-8 in web page encoding

First of all, we need to understand that GB2312, ...

Docker removes abnormal container operations

This rookie encountered such a problem when he ju...