"; "classname" specifies the name of the element's class, if necessary An element specifies multiple classes, using spaces to separate class names."/> "; "classname" specifies the name of the element's class, if necessary An element specifies multiple classes, using spaces to separate class names.">

Home  >  Article  >  Web Front-end  >  What is the class of html?

What is the class of html?

青灯夜游
青灯夜游Original
2021-10-29 17:58:0825152browse

class is an attribute in the HTML tag, used to define the class name of the element, corresponding to the class selector in CSS, the syntax "<element class="classname">"; "classname" specifies the element The name of the class. If you need to specify multiple classes for an element, separate the class names with spaces. <element class="classname">

What is the class of html?

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

class is an attribute in the html tag. In HTML5, the class attribute can be used on any HTML element (it will validate any HTML element. But it is not necessarily useful).

The class attribute defines the class name of the element.

The class attribute is usually used to point to the class of the style sheet. However, it can also be used in JavaScript (via the HTML DOM) to modify the class name of an HTML element.

Syntax

<element class="classname">
  • classname: Specifies the name of the class of the element. To specify multiple classes for an element, separate the class names with spaces. . Multiple classes are allowed for HTML elements.

Naming rules for classname:

  • must start with the letters A-Z or a-z

  • can be The following characters: (A-Za-z), numbers (0-9), bar ("-"), and underscore ("_")

  • In HTML, class The name is case sensitive

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style>
h1.intro 
{
	color:blue;
}
p.important 
{
	color:green;
}
</style>
</head>
<body>

<h1 class="intro">标题 1</h1>
<p>段落。</p>
<p class="important">注意:这是一个很重要的段落。 :)</p>

</body>
</html>

What is the class of html?

## Recommended tutorial: "

html video tutorial"

The above is the detailed content of What is the class of html?. 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