国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
class and id: for positioning and style
Style: Inline style settings
紅色標(biāo)題
Title: Mouse hover prompt
src and href: link external resources
Home Web Front-end HTML Tutorial What are common HTML attributes (e.g., class, id, style, title, src, href)?

What are common HTML attributes (e.g., class, id, style, title, src, href)?

Jun 22, 2025 am 12:53 AM
Commonly used html attributes

HTML attributes are used to add extra information to tags, class and id are used for positioning and styles, class is reusable, id is unique; style is used for inline styles, but is not recommended for large-scale use; title provides mouse hover prompts; src introduces external resources such as pictures and scripts, and href specifies link address; other commonly used attributes include alt, placeholder, target="_blank" and rel="nofollow".

HTML attributes are the way to add extra information to tags, which usually appear in the start tags to control the behavior, style, or connections to other resources. There are many common HTML attributes, and the following are the most commonly used and worthy of mastery.


class and id: for positioning and style

These two properties are mainly used for CSS style settings and JavaScript operations.

  • class : You can use the same class name for multiple elements, which is suitable for setting styles or manipulating a set of elements.
    • For example: <p class="highlight">這是一段高亮文字</p>
  • id : Each id should be unique in the page and is often used for styles or JS operations of specific elements.
    • For example: <div id="main-content">主要內(nèi)容區(qū)域</div>

Simply put, if you want to control multiple elements, use class ; if you want to target only one specific element, use id .


Style: Inline style settings

style attribute allows you to write CSS styles directly on HTML elements. Although it is not recommended to use a lot (not conducive to maintenance), it is convenient for some minor tweaks.

  • Example: <h1 id="紅色標(biāo)題">紅色標(biāo)題</h1>

It is recommended to only use it in a small amount of dynamically generated content, otherwise it is better to write it in a CSS file in a concentrated manner.


Title: Mouse hover prompt

The small prompt box displayed when you place the mouse on an element is controlled by title attribute.

  • Example: <a href="#" title="點(diǎn)擊返回頂部">回到頂部</a>

This property also plays a role in accessibility and user experience, but don't rely too much on it to deliver critical information.


These two properties are used to introduce external resources, but have different uses:

  • src : used for <img src="/static/imghw/default1.png" data-src="image.jpg" class="lazy" alt="What are common HTML attributes (e.g., class, id, style, title, src, href)?" > , <script></script> and other tags, indicating "I want to load this file".
    • Example: <img src="/static/imghw/default1.png" data-src="image.jpg" class="lazy" alt="What are common HTML attributes (e.g., class, id, style, title, src, href)?">
  • href : mainly used in the <a></a> and <link> tags, indicating "This is a link address".
    • Example: <a href="https://example.com">跳轉(zhuǎn)到示例網(wǎng)站</a>

Simple notation: src is "I want to load" and href is "You can go here".


There are also some commonly used attributes you may see frequently, such as:

  • alt : Image alternative text, important for SEO and accessibility
  • placeholder : prompt text in the input box
  • target="_blank" : Let the link open in a new window
  • rel="nofollow" : Tell search engines not to track the link

Basically all of this is it. Once you master these, you can deal with most scenarios when writing HTML.

The above is the detailed content of What are common HTML attributes (e.g., class, id, style, title, src, href)?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Learn the canvas framework and explain the commonly used canvas framework in detail Learn the canvas framework and explain the commonly used canvas framework in detail Jan 17, 2024 am 11:03 AM

Explore the Canvas framework: To understand what are the commonly used Canvas frameworks, specific code examples are required. Introduction: Canvas is a drawing API provided in HTML5, through which we can achieve rich graphics and animation effects. In order to improve the efficiency and convenience of drawing, many developers have developed different Canvas frameworks. This article will introduce some commonly used Canvas frameworks and provide specific code examples to help readers gain a deeper understanding of how to use these frameworks. 1. EaselJS framework Ea

PHP regular expression in action: matching HTML attributes PHP regular expression in action: matching HTML attributes Jun 22, 2023 pm 09:29 PM

In web development, HTML attributes are one of the very important elements. However, in actual development, it is often necessary to match and extract attributes. At this time, regular expressions become a very effective tool. This article will introduce how to use PHP regular expressions to match HTML attributes, and explain it with actual cases. First, we need to understand the general structure of HTML attributes. An HTML attribute usually consists of an attribute name and an attribute value, connected by an equal sign. For example: class="container

Spring Annotation Revealed: Analysis of Common Annotations Spring Annotation Revealed: Analysis of Common Annotations Dec 30, 2023 am 11:28 AM

Spring is an open source framework that provides many annotations to simplify and enhance Java development. This article will explain commonly used Spring annotations in detail and provide specific code examples. @Autowired: Autowired @Autowired annotation can be used to automatically wire beans in the Spring container. When we use the @Autowired annotation where dependencies are required, Spring will find matching beans in the container and automatically inject them. The sample code is as follows: @Auto

Using $attrs to pass HTML attributes in Vue Using $attrs to pass HTML attributes in Vue Jun 11, 2023 am 11:35 AM

Vue is a popular JavaScript framework for building modern web applications. Vue provides a powerful component system that allows you to break down UI elements into reusable parts and combine them in a maintainable way. Vue's component system also provides a convenient way to pass data and properties between components. One very useful way to pass attributes is $attrs. $attrs is a special object provided by Vue for passing the HTML attributes of a component to its subgroups

What are the commonly used encryption algorithms in PHP? What are the commonly used encryption algorithms in PHP? May 12, 2023 pm 06:51 PM

With the development of the Internet, data security has become a serious issue that we must pay attention to in our daily work. Encryption becomes especially important when it comes to sensitive personal information or business data. In PHP development, some encryption algorithms are widely used. Let's take a look at the encryption algorithms commonly used in PHP. 1. Base64 encoding Base64 encoding is often used to transmit binary data in web pages or emails, because web pages or emails can only transmit string type data and cannot directly transmit binary data. Base64 is a solution

What are boolean attributes in HTML? Give some examples. What are boolean attributes in HTML? Give some examples. Apr 25, 2025 am 12:01 AM

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.

15 commonly used currency circle escape index technology analysis 15 commonly used currency circle escape index technology analysis Mar 03, 2025 pm 05:48 PM

In-depth analysis of the top 15 Bitcoin Escape Index: Market Outlook for 2025 This article deeply analyzes fifteen commonly used Bitcoin Escape Index, among which the Bitcoin Rhodl ratio, USDT current wealth management and altcoin seasonal index have reached the Escape Index in 2024, attracting market attention. How should investors deal with potential risks? Let us interpret these indicators one by one and explore reasonable response strategies. 1. Detailed explanation of key indicators AHR999 coin hoarding indicator: Created by ahr999, assisting Bitcoin fixed investment strategy. The current value is 1.21, which is in the wait-and-see range, so it is recommended to be cautious. Link to AHR999 Escape Top Indicator: A supplement to AHR999 Coin Hoarding Indicator, used to identify the top of the market. The current value is 2.48, this week

What are the commonly used functions in Go language? What are the commonly used functions in Go language? Mar 28, 2024 pm 02:45 PM

What are the commonly used functions in Go language? ——Explore commonly used functions and their usage in Go language. As a popular statically typed programming language, Go language is widely used in various fields, such as server-side development, network programming, cloud computing, etc. In the Go language, functions, as the basic code organization unit, are an important part of program running. This article will explore the commonly used functions and their usage in the Go language to help readers better grasp the core features of this language. 1. Function declaration and calling functions in Go language with the keyword "fun

See all articles