To code lyrics in HTML, put each verse or chorus in its own paragraph and use <br> where a lyric line must end. Add headings when readers need to jump between song sections. Use CSS for spacing, type size and wrapping. A static lyrics page needs no JavaScript.
The difficult part is usually preserving the song’s lines without making the page awkward on a phone. Pressing Enter in your HTML source does not normally create a visible line break. Making every line a heading causes a different problem: the navigation structure stops describing the song. This guide separates those decisions and gives you a complete page to adapt.

How to code lyrics in HTML: start with one stanza
Begin with a short verse, not a complicated music player. The paragraph groups the stanza, while each break marks a line ending that belongs to the lyrics. The following words were invented for these examples; they are not a transcription of a released song.
<p>Morning gathers at the gate<br>Footsteps find the open road</p>
The browser displays two lines within one paragraph. The break element has no closing tag. Do not add an empty paragraph or several more breaks just to push the next verse down the screen. Give separate stanzas separate paragraphs, then adjust the distance between them with CSS.
There’s a difference in a line from lyrics, versus wrapping to the next line on the display (screen). A very long lyric will automatically be wrapped to the next display line if you make your window too small. The wording has not changed; it did not add an additional stanza. Leave the intended wrap at the end of the original lyric line, and let the browser wrap as needed.
Choose paragraphs, headings and breaks deliberately
| Content | Useful markup | Purpose |
|---|---|---|
| Song title | One main heading | Identify the page |
| Verse or chorus label | Section heading | Help readers navigate |
| One stanza | Paragraph | Group related lines |
| Intentional line ending | Break element | Keep the authored division |
| Gap between stanzas | CSS margin | Control presentation |
Not all stanzas will need to have a visible label. A short piece of music can work well with just a title and a few paragraphs. Longer pieces or teaching pages are much easier for users to navigate when you include descriptive labels like Verse 1 or Chorus. Do not label your general comments as verses. Keep your explanations out of the paragraphs that contain lyrics.
UC Davis explains the difference between semantic headings and visual styles. Apply that distinction here: choose a heading because it names a section, then style it. Making text large or bold does not by itself create a useful heading structure.
Build a complete lyrics page
Save this document as lyrics.html and open it in a browser. It includes a responsive viewport, a descriptive document title, a main content area, two named sections and a working chorus jump link. The example’s heading belongs inside its standalone document; it is not an extra title to paste above a WordPress post title.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Open Road — original example lyrics</title>
<style>
body { font: 1rem/1.7 system-ui, sans-serif; margin: 0; color: #172b3a; }
main { max-width: 42rem; margin-inline: auto; padding: 1.5rem; }
.stanza { margin-block: 0 1.75rem; overflow-wrap: anywhere; }
h2 { margin-top: 2rem; }
a:focus-visible, summary:focus-visible { outline: 3px solid #125e91; }
</style>
</head>
<body>
<main>
<h1>Open Road</h1>
<p>Original example lyrics for learning HTML.</p>
<nav aria-label="Song sections"><a href="#chorus">Jump to chorus</a></nav>
<section aria-labelledby="verse-one">
<h2 id="verse-one">Verse 1</h2>
<p class="stanza">Morning gathers at the gate<br>
Footsteps find the open road<br>
Every window holds a story<br>
Every pocket holds a hope</p>
</section>
<section aria-labelledby="chorus">
<h2 id="chorus">Chorus</h2>
<p class="stanza">Carry daylight through the city<br>
Let the quiet voices grow</p>
</section>
</main>
</body>
</html>
Click on the Chorus link and make sure it takes you to the correct section. The fragment identifier in your link and section ID need to be identical. Give each target section its own ID. If there are multiple songs per page, use a short song name as the prefix for each section ID; this will keep chorus labels from colliding.
Next, replace the invented words with material you have permission to publish. Keep punctuation and meaningful line divisions from your source. Do not add a performance credit, songwriter name or translation credit unless it is accurate. A code sample should make it clear which content is an example and which content describes a real recording.
Style spacing and wrapping without breaking the song
Start with a reasonable line spacing and a readable column. Limiting the width of your content will also keep your shorter lyrics from being stretched out when viewed on larger monitors. Adding padding ensures that your content is far enough from the edges of the screen. Using relative units for fonts allows you to follow users’ text preferences in their browsers as opposed to setting each value based off a single screenshot.
Let long lines wrap. Avoid a fixed height on the stanza, which can clip text after a font change or zoom. Avoid forcing every line to stay on one row, which can make a phone page scroll sideways. Word wrapping is preferable to shrinking the text until it becomes hard to read.
The sample includes overflow-wrap as a safeguard for an unusually long unbroken string. It does not preserve poetic rhythm or decide where a musical phrase ends. Those are editorial choices represented by the actual breaks in the markup. Leave ordinary words intact when there is enough space.
Keep your rules scoped to a song container on an existing website. A global paragraph rule can change menus, captions and unrelated articles. If you move the sample’s rules into a separate file, our guide to linking CSS to HTML explains where the stylesheet link belongs and how relative paths work.
Keep newlines when lyrics arrive as plain text
If your source already contains newline characters, you can preserve them with a whitespace rule instead of inserting a break element after each line. This is useful for a small text import. Keep separate stanza containers when readers need the stanza grouping to remain clear.
<p class="plain-lyrics">Morning gathers at the gate
Footsteps find the open road</p>
<style>
.plain-lyrics { white-space: pre-line; }
</style>
With pre-line, source line endings are preserved while repeated spaces collapse. With pre-wrap, repeated spaces are preserved as well, and the text can still wrap. Choose the latter only when those spaces carry meaning. Indentation added for neat source formatting can otherwise appear as unwanted visual spacing.
A preformatted element preserves whitespace by default, but its usual presentation is not necessarily suitable for a lyrics page. If you choose it, supply readable typography and wrapping rules. The choice should follow the content rather than serve as a shortcut around understanding line breaks. Our HTML new-line guide compares the common approaches.
For text inserted by a script, assign plain text as textContent rather than interpreting it as HTML. That keeps characters such as angle brackets from becoming markup. Apply the whitespace rule to the destination element. This short example assumes that the paragraph with the matching class already exists.
const stanza = document.querySelector('.plain-lyrics');
stanza.textContent = 'Morning gathers at the gatenFootsteps find the open road';
Keep lyrics readable alongside audio
A static lyrics page and a synchronized karaoke display are different projects. HTML line breaks do not supply timestamps. Following playback needs timing data, a player and logic that keeps the current line aligned with the recording. Start with accessible static text before adding that behavior.
If you add a recording, use visible playback controls and let visitors choose when sound starts. Keep the words available without playback or animation. Highlighting a current line should supplement the readable page, not replace it or hide all the other lines.
A lyric sheet may not describe spoken introductions or other meaningful audio. The University of Washington’s transcript guidance explains the role of a text alternative to audio. Check the actual recording and provide the information a listener would otherwise miss; do not assume a list of sung words describes every part.
Use real headings and selectable text. The University of Virginia’s accessible-text guidance discusses titles, headings and the problems with images of text. A screenshot of a verse should not be the only place its words appear. Distinguish meaningful breaks within lyrics from the separate paragraphs needed for surrounding commentary.
Fix common lyrics formatting problems
| Symptom | What to inspect | Fix |
|---|---|---|
| All lines merge | Normal whitespace handling | Add meaningful breaks or preserve newlines |
| Huge gaps appear | Repeated breaks and margins | Use one stanza container and controlled margins |
| Words spill sideways | Fixed widths or nowrap | Allow wrapping and responsive width |
| Tags appear as text | Editor mode or escaped input | Put markup in an HTML-capable editing area |
| Jump link misses | Fragment spelling or duplicate IDs | Use one exact unique target |
Keep the source text easy to maintain
Keep a clean text copy of the lyrics separate from your page styling. When a word changes, update the content rather than adjusting spaces until the line looks right again. A layout that depends on a particular number of spaces is fragile when the font, window width or wording changes.
When you are repeating choruses in your lyrics, determine how much of this information does the reader need. If a full reading version is needed (i.e., all the complete lyrics), writing out the entire chorus would create that. For rehearsal purposes, a shorter version of the instructions for repetition might be suitable; however, they are two different documents. Do not use abbreviations as substitutions for written-out words without defining them when you want to display the full text.
Save your text files as UTF-8. Leave the charset declaration in all standalone examples. If you see an apostrophe or accented letter that is interpreted as an unexpected character, check how you’ve saved the file before modifying the markup. In the case of needing a literal less-than in lyrics, use an HTML character reference for the less-than sign or add the content to the page using a safe script example. Never consider imported text as trusted HTML.
Check the finished result
Compare the rendered words with the source, including repeated choruses. Resize the window, zoom the text and inspect the longest line. Try selecting and copying a stanza. Check that meaningful words remain present when images fail to load and that nothing depends solely on a color change.
On a CMS site, look at the original saved version of that page and the version you edited in the editor. An editor can insert new lines (paragraphs) or modify the source code’s format. Look at your final published version for breaks prior to deciding if your successful edit has kept all breaks. Use Tab to get to the next question in the self-check below. Once on it, press Enter to see its answer.
FAQs and a short self-check
Is there a special HTML lyrics tag?
No. Combine ordinary headings, paragraphs and meaningful line breaks. A descriptive class can help you style those elements, but it does not create a new HTML element.
Should every lyric line be a list item?
Usually not. Use a list when the content is genuinely a list. A stanza with intentional line divisions is generally better represented as grouped text.
Can HTML synchronize lyrics with music?
Static markup alone does not manage playback timing. Synchronized highlighting needs additional data and behavior. Keep a readable text version available regardless of that enhancement.
Self-check: which creates space between verses, repeated breaks or CSS margins?
CSS margins. Keep each stanza grouped and adjust its spacing rather than inserting empty lines for layout.
Self-check: does a soft wrap change the original lyric line?
No. A narrow display may wrap a long line. The authored break still identifies where that lyric line ends.