Is it possible to set the equivalent of a src attribute of an img tag in CSS?

后端 未结 25 2593
借酒劲吻你
借酒劲吻你 2020-11-22 09:30

Is it possible to set the src attribute value in CSS? At present, what I am doing is:


25条回答
  •  滥情空心
    2020-11-22 10:00

    I know this is a really old question however no answers provide the proper reasoning for why this can never be done. While you can "do" what you are looking for you cannot do it in a valid way. In order to have a valid img tag it must have the src and alt attributes.

    So any of the answers giving a way to do this with an img tag that does not use the src attribute are promoting use of invalid code.

    In short: what you are looking for cannot be done legally within the structure of the syntax.

    Source: W3 Validator

提交回复
热议问题