Noscript

Struct Noscript 

Source
pub struct Noscript;
Expand description

The <noscript> element - defines fallback content for when scripts are disabled.

§Purpose

The <noscript> element provides fallback content for users who have disabled scripts or use browsers that don’t support scripting. The content inside is only displayed when scripting is unavailable. Useful for providing alternative content, instructions, or degraded experiences.

§Content Categories

  • Metadata Content (when used in <head>)
  • Flow Content (when used in <body>)
  • Phrasing Content (when used in <body>)

§Permitted Content Model

  • When in <head>: <link>, <style>, and <meta> elements
  • When in <body>: Transparent content (with restrictions)

§Common Use Cases

  • Providing messages about enabling JavaScript
  • Offering alternative navigation when scripts fail
  • Displaying static content as fallback
  • Showing contact information when forms require JavaScript
  • Providing download links for content requiring scripts

§Key Attributes

  • Global attributes only

§Example

<!-- Message in head for styles -->
<head>
  <noscript>
    <style>
      .js-only { display: none; }
    </style>
  </noscript>
</head>

<!-- Alternative content in body -->
<noscript>
  <div class="alert">
    <p>This website requires JavaScript to function properly.</p>
    <p>Please enable JavaScript in your browser settings.</p>
  </div>
</noscript>

<!-- Fallback for dynamic content -->
<div id="app">
  <noscript>
    <p>Our interactive application requires JavaScript.</p>
    <p>You can still <a href="/static-version">view the static version</a>.</p>
  </noscript>
</div>

<!-- Alternative form submission -->
<form id="ajax-form" action="/submit" method="post">
  <noscript>
    <p>JavaScript is disabled. Please use the traditional form submission.</p>
    <input type="submit" value="Submit Form">
  </noscript>
</form>

§Accessibility

  • Ensure noscript content is meaningful and helpful
  • Provide clear instructions for enabling JavaScript if required
  • Consider whether your site should work without JavaScript
  • Test the experience with scripting disabled

§WHATWG Specification

Trait Implementations§

Source§

impl HtmlElement for Noscript

Source§

const TAG: &'static str = "noscript"

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 CanContain<Noscript> for Head

Source§

impl<T: FlowContent> CanContain<T> for Noscript

Source§

impl FlowContent for Noscript

Source§

impl MetadataContent for Noscript

Source§

impl PhrasingContent for Noscript

Auto Trait Implementations§

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.