What is the cite attribute for?

前端 未结 7 1923
醉话见心
醉话见心 2021-02-05 10:01

The cite attribute specifies the address of the source of the quoted text, I think, but who uses this information?

For example:



        
相关标签:
7条回答
  • 2021-02-05 10:42

    First, it's not only blockquote where you can use the cite attribute. You can use the cite attribute on the following elements also:

    <blockquote>
    <del>
    <ins>
    <q>
    

    Why would one use cite in above elements?

    To point to where the content is taken from, or change or deletion is referred.


    Here is what w3.org says,

    User agents may allow users to follow such citation links, but they are primarily intended for private use (e.g: by server-side scripts collecting statistics about a site's edits), not for readers


    Now, the question, who uses it?

    The cite attribute is used to identify the online source of the quotation in the form of a URI (for example, "http://sourcewebsite.doc/document.html").

    The value of the cite attribute isn't rendered on screen (although this potentially useful meta data could be extracted and written back into the webpage through the magic of DOM Scripting).

    As such, browser support for this attribute is marked as none, but because it has other potential uses (for search engine indexing, retrieval via DOM scripting, and more) and there is the likelihood of improved native support being provided for the attribute in future browser versions, you should use the cite attribute when you use the above elements.

    So, currently no one uses it, but in future maybe used in user-agent or my search engines, so better to use it.

    0 讨论(0)
  • 2021-02-05 10:44

    W3C has this to say:

    The value of this attribute is a URI that designates a source document or message. This attribute is intended to give information about the source from which the quotation was borrowed.

    It's not visible and I can't think of anywhere it's used except perhaps by search engines.

    0 讨论(0)
  • 2021-02-05 10:50

    Both the <cite> tag and the cite attribute are for semantic purposes, which means that they are simply for giving a website more "meaning". For example, I could use a <div> tag for a quote, rather than using a <blockquote> tag, but this provides less meaning to the browser, and hence using <blockquote> is recommended for quotes.

    The same is with the <cite> tag and cite attributes. As per the MDN definition for the cite attribute (link here):

    Use the cite attribute on a or element to reference an online resource for a source.

    "so who does use this information, and how?" - I believe that search engines (e.g. Google) would use this information to show potential links between documents. If you think about this it is a major point. Check out the image below:

    Search of Samsung on Google

    Notice how it shows the "Samsung Group" information box on the right. The guys who work at Google don't write this information - rather, it is sourced from Wikipedia. However, this information would be of greater relevance to the search "samsung" when this information is also written on other websites, with the cite attribute linking this information to Wikipedia (hence increasing the relevancy of Wikipedia). This is why Wikipedia's information is used here, and not some primary school's website regarding Samsung phones.

    The cite attribute simply provides more meaning to the website. Tim Berners-Lee has described the semantic web as a component of "Web 3.0" - in other words, many components of the updating HTML language are simply to provide more meaning onto the webpage, as a step closer to Web 3.0.

    TL;DR - in simpler terms, the cite attribute is just to provide more meaning to the web page, and may be used for search engines for better web linkage.

    0 讨论(0)
  • 2021-02-05 10:54

    Yes, the source of the quotation isn't visible to end user. So it's just a reference to the source.

    Definition from WHATWG.ORG:

    Content inside a q element must be quoted from another source, whose address, if it has one, may be cited in the cite attribute. The source may be fictional, as when quoting characters in a novel or screenplay.

    If the cite attribute is present, it must be a valid URL potentially surrounded by spaces.

    0 讨论(0)
  • 2021-02-05 10:58

    It is meant to be used by machine which collect and arrange data eg. search engines, but it can be used by any machine. It is meant to make webpages more systematic to be read by machine. As they can not understand which part of text represent citation and quote based on only context. you can look up Semantic Web for more information. http://en.wikipedia.org/wiki/Semantic_Web

    0 讨论(0)
  • 2021-02-05 10:59

    It's just another meta data chunk that can be used by server side scripts to collect statistics or by front end developpers to add functionnalities (they can choose to print the source, allow to access the original source, etc...).

    It's just a good practice to have the original source written somewhere although it is actually not very useful for the end user.

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