Skip to main content
Standard HTML elements accept content and always have a closing tag. Each method accepts keyword arguments for attributes and a block for content.

Usage

All standard element methods follow this signature:
element_name(**attributes, &content)

Examples

class MyView < Phlex::HTML
  def view_template
    div(class: "container") do
      h1 { "Welcome" }
      p(id: "intro") { "This is a paragraph" }
      a(href: "/about") { "About Us" }
    end
  end
end
# With multiple attributes
button(type: "submit", class: "btn btn-primary", disabled: true) do
  "Submit Form"
end
# Nested elements
ul(class: "menu") do
  li { a(href: "/home") { "Home" } }
  li { a(href: "/about") { "About" } }
  li { a(href: "/contact") { "Contact" } }
end

Available Elements

ElementDescriptionMDN DocsSpec
htmlRoot elementMDNSpec
headDocument metadata containerMDNSpec
bodyDocument bodyMDNSpec
titleDocument titleMDNSpec
styleEmbedded CSSMDNSpec
ElementDescriptionMDN DocsSpec
headerIntroductory contentMDNSpec
navNavigation sectionMDNSpec
mainMain contentMDNSpec
sectionGeneric sectionMDNSpec
articleSelf-contained contentMDNSpec
asideAside contentMDNSpec
footerFooter contentMDNSpec
addressContact informationMDNSpec
hgroupHeading groupMDNSpec
searchSearch sectionMDNSpec
divGeneric containerMDNSpec
ElementDescriptionMDN DocsSpec
h1Heading level 1MDNSpec
h2Heading level 2MDNSpec
h3Heading level 3MDNSpec
h4Heading level 4MDNSpec
h5Heading level 5MDNSpec
h6Heading level 6MDNSpec
ElementDescriptionMDN DocsSpec
pParagraphMDNSpec
blockquoteBlock quotationMDNSpec
prePreformatted textMDNSpec
ulUnordered listMDNSpec
olOrdered listMDNSpec
liList itemMDNSpec
dlDescription listMDNSpec
dtDescription termMDNSpec
ddDescription detailsMDNSpec
figureFigure with captionMDNSpec
figcaptionFigure captionMDNSpec
menuMenu listMDNSpec
detailsDisclosure widgetMDNSpec
summarySummary for detailsMDNSpec
ElementDescriptionMDN DocsSpec
aAnchor/hyperlinkMDNSpec
abbrAbbreviationMDNSpec
bBold textMDNSpec
bdiBidirectional isolateMDNSpec
bdoBidirectional overrideMDNSpec
citeCitationMDNSpec
codeInline codeMDNSpec
dataMachine-readable dataMDNSpec
dfnDefinition termMDNSpec
emEmphasisMDNSpec
iItalic textMDNSpec
kbdKeyboard inputMDNSpec
markMarked/highlighted textMDNSpec
qInline quotationMDNSpec
sStrikethroughMDNSpec
sampSample outputMDNSpec
smallSmall textMDNSpec
spanGeneric inline containerMDNSpec
strongStrong importanceMDNSpec
subSubscriptMDNSpec
supSuperscriptMDNSpec
timeTime/dateMDNSpec
uUnderlineMDNSpec
varVariableMDNSpec
ElementDescriptionMDN DocsSpec
formForm containerMDNSpec
labelForm control labelMDNSpec
buttonInteractive buttonMDNSpec
selectDropdown selectMDNSpec
datalistInput options listMDNSpec
optgroupOption groupMDNSpec
optionSelect optionMDNSpec
textareaMulti-line text inputMDNSpec
outputCalculation resultMDNSpec
progressProgress indicatorMDNSpec
meterScalar measurementMDNSpec
ElementDescriptionMDN DocsSpec
fieldsetForm control groupingMDNSpec
legendFieldset captionMDNSpec
ElementDescriptionMDN DocsSpec
tableTable containerMDNSpec
captionTable captionMDNSpec
colgroupColumn groupMDNSpec
theadTable headerMDNSpec
tbodyTable bodyMDNSpec
tfootTable footerMDNSpec
trTable rowMDNSpec
thTable header cellMDNSpec
tdTable data cellMDNSpec
ElementDescriptionMDN DocsSpec
audioAudio contentMDNSpec
videoVideo contentMDNSpec
pictureResponsive imagesMDNSpec
canvasGraphics canvasMDNSpec
svgSVG graphicsMDNSpec
iframeNested browsing contextMDNSpec
objectExternal resourceMDNSpec
ElementDescriptionMDN DocsSpec
scriptExecutable codeMDNSpec
noscriptNo-script fallbackMDNSpec
templateTemplate contentMDNSpec
ElementDescriptionMDN DocsSpec
rubyRuby annotationMDNSpec
rtRuby textMDNSpec
rpRuby parenthesisMDNSpec
ElementDescriptionMDN DocsSpec
insInserted textMDNSpec
delDeleted textMDNSpec
ElementDescriptionMDN DocsSpec
dialogDialog boxMDNSpec
mapImage mapMDNSpec
ElementDescriptionMDN DocsSpec
slotWeb component slotMDNSpec
selectedcontentSelected content (EXPERIMENTAL)MDNDraft
ElementDescriptionMDN Docs
fencedframeFenced frame (EXPERIMENTAL)MDN

Total Count

99 standard HTML elements are available in Phlex.

See Also

Build docs developers (and LLMs) love