Is there a way to mimic the functionality of the attr() function in JavaScript? Specifically, I want to adjust the indentation of a paragraph based on the value of data-indent
, similar to how we use
p { text-indent: attr(data-indent em) }
.
<p data-indent=4>Hello World :-)</p>
EDIT: Although some may find my question trivial, @G-Cyrillus's response sheds light on an important concept. It dawned on me that inline styling is sometimes unavoidable, even though I initially preferred using HTML classes and IDs instead. This inquiry arose from an attempt to address another issue I had posted about. Thanks to this newfound knowledge, I can now effortlessly display tree data structures with an HTML table without relying on JavaScript.