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
hrefattribute) - 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 identifiertarget: 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
impl HtmlElement for A
impl<T: PhrasingContent> CanContain<T> for A
impl CanContain<Text> for A
impl FlowContent for A
impl InteractiveContent for A
impl PalpableContent for A
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more