pub struct Style;Expand description
The <style> element - embedded CSS styles.
§Purpose
The <style> element contains CSS style information for the document.
It allows you to embed styles directly in HTML without an external stylesheet.
§Content Categories
- Metadata Content
§Permitted Content Model
- Text content representing CSS rules
§Common Use Cases
- Embedding critical CSS for performance optimization
- Adding page-specific styles without a separate file
- Inline styles for email templates
- Dynamic styling that changes based on server-side conditions
§Key Attributes
media: Media query for conditional application of stylestype: MIME type (defaults to"text/css", usually omitted)nonce: Cryptographic nonce for Content Security Policy
§Example
<head>
<style>
body {
font-family: sans-serif;
margin: 0;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
</style>
<style media="print">
.no-print { display: none; }
</style>
</head>§WHATWG Specification
Trait Implementations§
Source§impl HtmlElement for Style
impl HtmlElement for Style
impl CanContain<Style> for Head
impl CanContain<Text> for Style
impl MetadataContent for Style
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
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