getting attribute from parent selector is CSS using content:attr();

前端 未结 1 1904
[愿得一人]
[愿得一人] 2021-01-11 11:31

Hey I am trying to place the \'title\' attribute of a

tag inside a

tag located just below and inside the
tag.The following works

相关标签:
1条回答
  • 2021-01-11 12:15

    The attr() function can only obtain an attribute from the element that's generating the content. You won't be able to get the section element's title because it's not the element that's generating the content.

    As ScottS mentions, you should really avoid having an empty heading element, as there wouldn't be a point in having it there at all then. Your best bet is to either leave out the title attribute (is it really needed?), or leave the content duplicated.

    0 讨论(0)
提交回复
热议问题