HTML属性_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:45:18
Original
1452 people have browsed it

HTML属性为 HTML 元素提供附加信息(提供了有关 HTML 元素的更多的信息)。

属性总是以名称/值对的形式出现,比如:name="value"。

属性总是在 HTML 元素的开始标签中规定。

<img src="1.jpg" alt="图片1" /><a href="www.aaa.html" title="aaa网址">aaa</a>
Copy after login

说明:img元素中包含src属性和alt属性;a元素中包含href和title属性。

src属性:引用图片,它的值是图像文件的 URL,可以是相对路径或绝对路径。

alt属性:规定在图像无法显示时的替代文本。

href属性:用于指定超链接目标的 URL,可以是相对路径或绝对路径。

title属性:规定关于元素的额外信息。试一下:aaa  这里我们可以把鼠标移动超链接文本(aaa)上,就会出现title的信息(aaa网址)。

 

通用属性

 

下面列出了适用于大多数 HTML 元素的属性:

属性 值 描述
class classname 规定元素的类名(classname)
id id 规定元素的唯一 id
style style_definition 规定元素的行内样式(inline style)
title text 规定元素的额外信息(可在工具提示中显示)

 

 

 

 

 

养成好习惯(XHTML属性语法规范)

  • XHTML 属性必须使用小写
  • XHTML 属性值必须用引号包围
  • XHTML 属性最小化也是禁止的
  • 用 Id 属性代替 name 属性
  • Related labels:
    source:php.cn
    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
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!