A

Struct A 

Source
pub struct A;
Expand description

The <a> element - hyperlink (anchor).

§Purpose

The <a> element creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other URL. It’s one of the most fundamental elements of the web, enabling navigation between resources.

§Content Categories

  • Flow Content
  • Phrasing Content
  • Interactive Content (if it has an href attribute)
  • Palpable Content

§Permitted Content Model

  • Transparent (inherits from parent), but must not contain interactive content

§Common Use Cases

  • Linking to other pages or websites
  • Creating in-page navigation (anchor links)
  • Downloadable file links
  • Email links (mailto:)
  • Telephone links (tel:)

§Key Attributes

  • href: URL or fragment identifier
  • target: Browsing context ("_blank", "_self", "_parent", "_top")
  • rel: Relationship to linked resource ("noopener", "noreferrer", "nofollow")
  • download: Suggests download instead of navigation

§Example

<p>Visit our <a href="https://example.com">website</a> for more information.</p>
<p><a href="#section2">Jump to Section 2</a></p>
<p><a href="mailto:info@example.com">Email us</a></p>
<p><a href="document.pdf" download>Download PDF</a></p>
<p><a href="https://external.com" target="_blank" rel="noopener">External link</a></p>

§Accessibility

  • Link text should be descriptive (avoid “click here”)
  • Screen readers announce links separately
  • Keyboard accessible by default

§WHATWG Specification

Trait Implementations§

Source§

impl HtmlElement for A

Source§

const TAG: &'static str = "a"

The HTML tag name (e.g., “div”, “span”, “img”).
Source§

const VOID: bool = false

Whether this is a void element (self-closing, no children allowed).
Source§

impl<T: PhrasingContent> CanContain<T> for A

Source§

impl CanContain<Text> for A

Source§

impl FlowContent for A

Source§

impl InteractiveContent for A

Source§

impl PalpableContent for A

Source§

impl PhrasingContent for A

Auto Trait Implementations§

§

impl Freeze for A

§

impl RefUnwindSafe for A

§

impl Send for A

§

impl Sync for A

§

impl Unpin for A

§

impl UnwindSafe for A

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.