简体   繁体   中英

P attribute inside <li> tag

I have seen this code from the tutorial that I'm studying. I searched for the purpose of the p attribute inside the li tag but found no answer. What is the purpose of that p attribute inside the li tag ?

$msgs .= "<li p=\"$no_of_paginations\" class=\"inactive\">Last</li>";

The purpose cannot be inferred from the code snippet. As such, the attribute, being not defined in any HTML specification or draft or browser-specific extension, has no effect beyond being stored as data into the p element node in the document tree.

Such an attribute, though invalid by the specs, can be used like any other attribute in styling (eg attribute selector .p ) in CSS or in scripting. In this case, it is probable , but by no means certain, that the attribute is meant to be used in scripting to carry a number as its value, with that number inserted with some server-side code, so that this value can be accessed in client-side scripting, as relating to a specific element.

The recommended way is to use data-* attributes instead, such as data-p , to avoid any risk of clashing with attribute names that might be introduced in some future HTML version.

它应该是一个自定义属性,可以在JavaScript代码中使用以获取某些信息。

The default HTML(whichever version) namespace doesn't have a purpose for "p" inside a li tag. If there's another namespace declared then that's where it's from. Other than that, it's not valid by w3 standards.

那只是一些javascript函数中使用的自定义标签

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM