Enum build_html::HtmlVersion
source · #[non_exhaustive]
pub enum HtmlVersion {
HTML5,
HTML4,
XHTML1_0,
XHTML1_1,
}
Expand description
Versions of the HTML (or XHTML) standard
These can be used to change the doctype and apply attributes to an HtmlPage
.
Example
assert_eq!(
HtmlPage::with_version(HtmlVersion::HTML5).to_html_string(),
"<!DOCTYPE html><html><head></head><body></body></html>"
);
assert_eq!(
HtmlPage::with_version(HtmlVersion::XHTML1_0).to_html_string(),
concat!(
r#"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "#,
r#""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"#,
r#"<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>"#,
),
)
Compliance With HTML Standards
Please note that while we allow users to specify the version of the HTML standard their page is written in, this library does not and will not check whether your page is actually valid in that standard. Our feature set is targeting development in HTML5 and it is possible that some tags or attributes may not be valid in older HTML versions. You are responsible for knowing which subset of the provided features are valid for your chosen version. Use this feature at your own risk.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
HTML5
HTML 5. The current and preferred version of the HTML standard.
HTML4
Legacy HTML 4.01. Potentially useful for supporting old browsers.
XHTML1_0
Legacy XHTML 1.0. This is still common in HTML emails for backwards compatibility with different email clients.
XHTML1_1
Legacy XHTML 1.1.
Implementations§
source§impl HtmlVersion
impl HtmlVersion
sourcepub fn doctype(&self) -> &'static str
pub fn doctype(&self) -> &'static str
Return the DOCTYPE (DTD) that corresponds to this version of the HTML standard
sourcepub fn html_attrs(&self) -> Attributes
pub fn html_attrs(&self) -> Attributes
Return the set of attributes that should be applied to the HtmlPage
’s opening HTML tag