"; "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?
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">
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>## 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!