日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

HTML中的类属性

發布時間:2025/3/11 HTML 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HTML中的类属性 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

The class attribute in HTML is used to specify or set a single or multiple class names to an element for an HTML and XHTML elements. Its majorly used to indicate a class in a style sheet.

HTML中的class屬性用于為HTML和XHTML元素指定或設置一個元素名稱或多個類名稱。 它主要用于指示樣式表中的類。

Defining the structure of a class can also be considered as description to class attribute. You can identify them as the opening tags to control an element's behaviour. The class attribute often points to the class in the style sheet. Class attribute can also be taken in use by JavaScript, CSS (Cascading Style Sheet). The class name can be used by JavaScript and CSS to perform task or indulge changes for elements under specified class name; mainly for styling purposes or to add behaviour to elements that fall under particular subtype. Class attribute makes it liable to bring changes to any HTML element.

定義類的結構也可以視為對類屬性的描述。 您可以將它們標識為開始標簽,以控制元素的行為。 class屬性通常指向樣式表中的類。 JavaScript,CSS(級聯樣式表)也可以使用Class屬性。 JavaScript和CSS可以使用該類名來執行任務或放任指定類名下的元素更改。 主要用于樣式設計或為屬于特定子類型的元素添加行為。 使用Class屬性可以對任何HTML元素進行更改。

It determines how an element should processed, it will indicate the elements' inheritance and therefore how it should be handled. Name of an element specifies its type but class lets you assign to it one or more subtypes.

它確定元素應如何處理,將指示元素的繼承以及因此應如何處理。 元素的名稱指定了它的類型,但是類使您可以為其分配一個或多個子類型。

The class attributes cannot be applied to following elements,

類屬性不能應用于以下元素 ,

  • Base

    基礎

  • Basefont

    Basefont

  • Head

  • Html

    HTML

  • Meta

  • Para

    帕拉

  • Script

    腳本

  • Style

    樣式

  • Title

    標題

Class attributes can be used on inline elements.

類屬性可用于內聯元素。

There can be multiple class names to a single element where each class name must be separated by space between them, and also class attribute value may begin with a number and still be valid HTML unlike id attribute. But it is most likely to be avoided to initiate with a digit.

單個元素可以有多個類名,每個類名之間必須用空格隔開,并且類屬性值可以以數字開頭,并且仍然是有效HTML(與id屬性不同)。 但是最有可能避免以數字開頭。

It is recommended to have semantically meaningful name as possible as it would add to the emphasis of the particular subtype to be specific and would provide an eye of interest and ease to those reading the markup. Purely presentational names would help bring maximum eyes on board.

建議使用盡可能在語義上有意義的名稱,因為這會增加對特定子類型的強調,并為感興趣的人提供便利,并使閱讀標記的人感到輕松。 純粹的表述性名稱將有助于最大程度地吸引人們的注意。

The syntax which is however the essential format is,

但是語法是基本格式,

<element class="classname">

有關如何放置class屬性的示例? (An example on how to place the class attribute?)

<html><head><style>h1.intro {color: blue;}p.important {color: green;}</style> </head><body><h1 class="intro">Header 1</h1><p>A paragraph.</p><p class="important">Any important text. :)</p> </body></html>

All the styling and other changes in behavior in an element or elements that you want to provide to all the elements under the same section which is distinguished due to the class attribute can be applied in effect to every element. This in HTML provides a lot of potentials to work with and deal with several arrays of classes.

您想要提供給同一節下所有元素的一個元素或多個元素的所有樣式和其他行為更改(由于類屬性而有所區別)可以有效地應用于每個元素。 HTML中的這提供了使用和處理多個類數組的大量潛力。

Different tags can have the same class name and therefore share the same styles as well.

不同的標簽可以具有相同的類名,因此也可以共享相同的樣式。

The browsers that are compatible with class attributes are,

與類屬性兼容的瀏覽器是

  • Google Chrome

    谷歌瀏覽器

  • Internet Explorer

    IE瀏覽器

  • Firefox

    火狐瀏覽器

  • Opera

    歌劇

  • Safari

    蘋果瀏覽器

It's one of the basic aspects but essential that you need to know in attributes for HTML. And also quite easy to grasp in with.

這是基本方面之一,但您需要在HTML屬性中必須了解。 而且也很容易掌握。

翻譯自: https://www.includehelp.com/html/class-attribute-in-html.aspx

總結

以上是生活随笔為你收集整理的HTML中的类属性的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。