How to semantically tag poem text? - html

What to use for poem?
pre
blockquote
code
something else?

Don't use code (unless computer code is part of the poem). Don't use blockquote (unless you quote a poem).
white space / line breaks: pre or br
You may use the pre element. The spec gives an (informative) example:
The following shows a contemporary poem that uses the pre element to preserve its unusual formatting, which forms an intrinsic part of the poem itself.
<pre> maxling
it is with a heart
heavy
that i admit loss of a feline
so loved
a friend lost to the
unknown
(night)
~cdr 11dec07</pre>
However, I'd only use the pre element if the poem contains "more" than just meaningful line breaks (e.g. in this example the horizontal whitespace is meaningful).
If you have a simple poem, I'd go with the br element:
br elements must be used only for line breaks that are actually part of the content, as in poems or addresses.
container: p
For most poems, the p element is the right candidate (or several p elements, of course). The spec has an (informative) example:
<p>There was once an example from Femley,<br>
Whose markup was of dubious quality.<br>
The validator complained,<br>
So the author was pained,<br>
To move the error from the markup to the rhyming.</p>
Also:
For instance, an address is also a paragraph, as is a part of a form, a byline, or a stanza in a poem.
structure: (article, figure)
Depending on the context (content, page structure, …), a sectioning element might be appropriate (article in most cases).
Also depending on the context, the figure element might be appropriate:
Here, a part of a poem is marked up using figure.
<figure>
<p>'Twas brillig, and the slithy toves<br>
Did gyre and gimble in the wabe;<br>
All mimsy were the borogoves,<br>
And the mome raths outgrabe.</p>
<figcaption><cite>Jabberwocky</cite> (first verse). Lewis Carroll, 1832-98</figcaption>
</figure>
But don't use these in general for all poems, it really depends on the page if their use is correct.
misc. & trivia
someone proposed a poetry element (→ Rejected)
someone proposed a microformat for poems
discussion in the w3.org wiki: Explicit Markup to Semantically Express Poetic Forms (thanks for the link, steveax)
see also: on the mailing list
similar question on Webmasters SE: How to mark up a poem in HTML for SEO

I've looked for the same information and, similarly, haven't found any definitive "best practices" -- so I figured I'd just have to figure out my own method. The <p> tag does make some sense as a stanza marker, with lines divided by <br>s, per the spec -- BUT I've found that that markup style doesn't provide enough flexibility.
Specifically, I wanted control over indentation. For instance, if a line runs too wide for the width of the text column, it shouldn't just break: its continuation should be indented. This hanging indent can be achieved only (as far as I know) if each line is its own block element. So in my case I've made each poetry line a <p> with a class (say, "poetry-line"). Then I can use the following CSS:
.poetry-line {
text-indent: -2em;
margin-left: 2em;
}
In another example, the poem I was posting indented every other line, with some irregularities at the ends of stanzas. I couldn't achieve this effect with just <br>s between each line. I had to create a new class for the "indented-line" and apply it manually.
I'm just sharing my experience. I guess my suggestion is that you use a block-level element for each line, for formatting purposes. This could be a <p>, or I guess you could use CSS to set a <span>'s "display" to "block". In any case, the spec's example with <br>s between lines won't work for most poetry, I think: each line needs to be its own element.

I was also looking for a good option of marking up a poem, and finally I got to make one myself; therefore I share it here with you, and I hope it might be useful to somebody.
<article itemscope itemtype="http://schema.org/CreativeWork">
<link itemprop="additionalType" href="https://dbpedia.org/ontology/Poem" />
<h2 itemprop="name">Lorem Ipsum</h2>
<h4 itemprop="author">Jane Doe</h4>
<section itemprop="hasPart" itemscope itemtype="http://schema.org/CreativeWork">
<link itemprop="additionalType" href="https://dbpedia.org/ontology/Strophe" />
<ul itemprop="text">
<li>Lorem ipsum dolor sit amet,</li>
<li>consectetur adipiscing elit,</li>
<li>sed do eiusmod tempor incididunt</li>
<li>ut labore et dolore magna aliqua.</li>
</ul>
</section>
<section itemprop="hasPart" itemscope itemtype="http://schema.org/CreativeWork">
<link itemprop="additionalType" href="https://dbpedia.org/ontology/Strophe" />
<ul itemprop="text">
<li>Ut enim ad minim veniam, consectetur</li>
<li>adipiscing elit, squis nostrud</li>
<li> exercitation ullamco laboris nisi</li>
<li>ut aliquip ex ea commodo consequat</li>
</ul>
</section>
</article>
This is a minimal markup, and you can also add complementary markup, for each verse, or for the date, the genre, or the book it was published in, etc.

Related

HTML poetry tags [duplicate]

What to use for poem?
pre
blockquote
code
something else?
Don't use code (unless computer code is part of the poem). Don't use blockquote (unless you quote a poem).
white space / line breaks: pre or br
You may use the pre element. The spec gives an (informative) example:
The following shows a contemporary poem that uses the pre element to preserve its unusual formatting, which forms an intrinsic part of the poem itself.
<pre> maxling
it is with a heart
heavy
that i admit loss of a feline
so loved
a friend lost to the
unknown
(night)
~cdr 11dec07</pre>
However, I'd only use the pre element if the poem contains "more" than just meaningful line breaks (e.g. in this example the horizontal whitespace is meaningful).
If you have a simple poem, I'd go with the br element:
br elements must be used only for line breaks that are actually part of the content, as in poems or addresses.
container: p
For most poems, the p element is the right candidate (or several p elements, of course). The spec has an (informative) example:
<p>There was once an example from Femley,<br>
Whose markup was of dubious quality.<br>
The validator complained,<br>
So the author was pained,<br>
To move the error from the markup to the rhyming.</p>
Also:
For instance, an address is also a paragraph, as is a part of a form, a byline, or a stanza in a poem.
structure: (article, figure)
Depending on the context (content, page structure, …), a sectioning element might be appropriate (article in most cases).
Also depending on the context, the figure element might be appropriate:
Here, a part of a poem is marked up using figure.
<figure>
<p>'Twas brillig, and the slithy toves<br>
Did gyre and gimble in the wabe;<br>
All mimsy were the borogoves,<br>
And the mome raths outgrabe.</p>
<figcaption><cite>Jabberwocky</cite> (first verse). Lewis Carroll, 1832-98</figcaption>
</figure>
But don't use these in general for all poems, it really depends on the page if their use is correct.
misc. & trivia
someone proposed a poetry element (→ Rejected)
someone proposed a microformat for poems
discussion in the w3.org wiki: Explicit Markup to Semantically Express Poetic Forms (thanks for the link, steveax)
see also: on the mailing list
similar question on Webmasters SE: How to mark up a poem in HTML for SEO
I've looked for the same information and, similarly, haven't found any definitive "best practices" -- so I figured I'd just have to figure out my own method. The <p> tag does make some sense as a stanza marker, with lines divided by <br>s, per the spec -- BUT I've found that that markup style doesn't provide enough flexibility.
Specifically, I wanted control over indentation. For instance, if a line runs too wide for the width of the text column, it shouldn't just break: its continuation should be indented. This hanging indent can be achieved only (as far as I know) if each line is its own block element. So in my case I've made each poetry line a <p> with a class (say, "poetry-line"). Then I can use the following CSS:
.poetry-line {
text-indent: -2em;
margin-left: 2em;
}
In another example, the poem I was posting indented every other line, with some irregularities at the ends of stanzas. I couldn't achieve this effect with just <br>s between each line. I had to create a new class for the "indented-line" and apply it manually.
I'm just sharing my experience. I guess my suggestion is that you use a block-level element for each line, for formatting purposes. This could be a <p>, or I guess you could use CSS to set a <span>'s "display" to "block". In any case, the spec's example with <br>s between lines won't work for most poetry, I think: each line needs to be its own element.
I was also looking for a good option of marking up a poem, and finally I got to make one myself; therefore I share it here with you, and I hope it might be useful to somebody.
<article itemscope itemtype="http://schema.org/CreativeWork">
<link itemprop="additionalType" href="https://dbpedia.org/ontology/Poem" />
<h2 itemprop="name">Lorem Ipsum</h2>
<h4 itemprop="author">Jane Doe</h4>
<section itemprop="hasPart" itemscope itemtype="http://schema.org/CreativeWork">
<link itemprop="additionalType" href="https://dbpedia.org/ontology/Strophe" />
<ul itemprop="text">
<li>Lorem ipsum dolor sit amet,</li>
<li>consectetur adipiscing elit,</li>
<li>sed do eiusmod tempor incididunt</li>
<li>ut labore et dolore magna aliqua.</li>
</ul>
</section>
<section itemprop="hasPart" itemscope itemtype="http://schema.org/CreativeWork">
<link itemprop="additionalType" href="https://dbpedia.org/ontology/Strophe" />
<ul itemprop="text">
<li>Ut enim ad minim veniam, consectetur</li>
<li>adipiscing elit, squis nostrud</li>
<li> exercitation ullamco laboris nisi</li>
<li>ut aliquip ex ea commodo consequat</li>
</ul>
</section>
</article>
This is a minimal markup, and you can also add complementary markup, for each verse, or for the date, the genre, or the book it was published in, etc.

How can I markup in semantically correct way additional info in header? html5?

I'm struggling with semantics, while I enjoy thinking about meaning of the parts of the websites, it is becoming complicated...
Anyhow, if I've additional info box in the header (imagine tall header, with nav and h1 + additional text explaining what website is about and how it works). What will be logical/semantic element to contain it?
<figure id="info_how">
<h2>Share what you will do for money, at the marketplace for small services!</h2>
<p>bibendum auctor, nisi elit consequat ipsum. Duis sed amet <strong>nibh vulputate cursus</strong> sit.</p>
<a id="button_start" href="#">Start selling</a>
<a id="button_how" href="#">How does it work?</a>
</figure>
I'm thinking figure, but...
According to the specs:
The figure element represents some flow content, optionally with a
caption, that is self-contained and is typically referenced as a
single unit from the main flow of the document.
The element can be used to annotate illustrations, diagrams, photos,
code listings, etc. This includes, but is not restricted to, content
referred to from the main part of the document, but that could,
without affecting the flow of the document, be moved away from that
primary content, e.g. to the side of the page, to dedicated pages, or
to an appendix.
So figure sounds good to me!
Additionally, I'd place a <figcaption> element inside of the <h2> tags:
<h2><figcaption>Share what you will do for money, at the marketplace for small services!</figcaption></h2>
Because it does represents the "caption" of the figure.

HTML5 block-quote with author

Hi I'm seeing a great number of different ways to implementat blockquote in html but it doesn't seem clear in its documentation how should I properly format a blockquote let's say of a famous quote and metion its author like:
In victory, you deserve Champagne, in defeat, you need it.
Napoleon Bonaparte
What would the correct format of that be in HTML5?
Should the author be inside or outside the blockquote tag?
Should it be inside the cite attribute? (even knowing the documentation specifies an URI , not author)
I googled about this and it looks like <figure> and <figcaption> should do the job:
<figure>
<blockquote cite="https://developer.mozilla.org/samples/html/figure.html">
Quotes, parts of poems can also be a part of figure.
</blockquote>
<figcaption>MDN editors</figcaption>
</figure>
https://developer.mozilla.org/samples/html/figure.html
<figure>
<blockquote cite="http://www.w3.org/html/wg/drafts/html/master/grouping-content.html#the-figure-element">
The figure element represents some flow content, optionally with a caption,
that is self-contained and is typically referenced as a single unit from the
main flow of the document.
</blockquote>
<figcaption>asdf</figcaption>
</figure>
http://www.w3.org/html/wg/drafts/html/master/grouping-content.html#the-figure-element
UPDATE 2020
WHATWG says about the blockquote element
Attribution for the quotation, if any, must be placed outside the
blockquote element.
WHATWG says about the cite element
The cite element represents the title of a work (e.g. a book, a paper,
[...])
A person's name is not the title of a work [...] and the element must
therefore not be used to mark up people's names.
So the following HTML it's fine:
<blockquote>
<p>In victory, you deserve Champagne, in defeat, you need it.</p>
</blockquote>
<p>— Napoleon Bonaparte</p>
OLD POST 2018
HTML 5.3 Editor’s Draft, 9 March 2018
W3C says about the cite element:
The cite element represents a reference to a creative work. It must
include the title of the work or the name of the author (person,
people or organization) or an URL reference, or a reference in
abbreviated form as per the conventions used for the addition of
citation metadata.
So the following HTML it's fine:
<blockquote>
Those who pass by us, do not go alone, and do not leave us alone;
they leave a bit of themselves, and take a little of us.
<cite>Antoine de Saint-Exupéry</cite>
</blockquote>
This is how Bootstrap does quotes in v3.3.
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
<footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
</blockquote>
More on the footer element from MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/footer
The HTML <footer> Element represents a footer for its nearest
sectioning content or sectioning root element (i.e, its nearest parent
<article>, <aside>, <nav>, <section>, <blockquote>, <body>, <details>,
<fieldset>, <figure>, <td>). A footer typically contains information
about the author of the section, copyright data or links to related
documents.
You may also consider using Structured Data, such as microdata, RDFa, and microformats.
http://neilpie.co.uk/2011/12/13/html5-quote-attribution/
For example, use
<small class="author">Napoleon Bonaparte<small>
HTML 5 documentation says, "Small print typically features disclaimers, caveats, legal restrictions, or copyrights. Small print is also sometimes used for attribution, or for satisfying licensing requirements."
My preference and it validates...
<!doctype html>
<html lang="en">
<head><title>Blockquote Test</title></head>
<body>
<div style="width:300px;border:1px solid #cecece; padding:10px;">
<blockquote cite="URL">
In victory, you deserve Champagne, in defeat, you need it.
</blockquote>
<div class="credit" style="text-align:right;">
<cite>Napoleon Bonaparte</cite>
</div>
</div>
</body>
</html>
This can be covered by Bootstrap 4 <footer class="blockquote-footer"> element:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<blockquote class="blockquote">
<p>In the digital age, knowledge is our lifeblood. And documents are the DNA of knowledge.</p>
<footer class="blockquote-footer">Rick Thoman, CEO, <cite title="Xerox Corporation">Xerox</cite></footer>
</blockquote>

Correct usage of HTML5 <hr> tag

I'm writing a new webpage for a company and I have (a sane subset of) HTML5/W3C recommendations in mind.
After reading the semantic meaning of <hr />, I was wondering if this was a good place to use it:
<section name="historyItem">
<h2>2002</h2>
<p>Dolorem ipsum dolor sit amet in 2002, consectetur [...]</p>
<hr />
<ul>
<li>Link A</li>
<li>Link B</li>
</ul>
</section>
My line of reasoning is that, yes, that <hr /> represents a thematic change from section description to section links, but I'm unsure about that.
Maybe "thematic change" means to have a new paragraph later on another subject, and thus my example wouldn't be "correct". What do you think?
(ps.: Yes, that <ul> is CSS-styled to fit a single line and look cool)
I see what you mean. But personally I just wouldn't bother. Ask yourself why you're using the tag in the first place. If you want to delineate a change between the paragraph and the links, then in terms of pure mark-up I don't reckon it's required. If it's about the look and feel of your page (i.e. you want a rule demarcating the two areas), then again I'd question its usefulness, given that you can apply a border to either the paragraph or unordered list tags.
Of course, given that this is html5, you could go the whole hog and use the <section> tag…
Thematically speaking, <hr> means the end of one "section" and the start of "another". Essentially these should be appearing after your <section> tags, not within. Although semantically speaking, it doesn't really matter where you want to use them.
If your list of link items are relevant to the items ABOVE the <hr> tag (meaning relevant to your other elements within the <section> tag, then I do not recommend using <hr> there. Instead, use CSS to differentiate border and underlines.
If you'd like additional reference, I've located this for you:
http://html5doctor.com/small-hr-element/

"Correct" way to mark up testimonials in HTML

I thought this would be an easy enough thing to find online but it seems not. I'm trying to find out what would be considered the correct way to mark up a list of testimonials - quotes with authors - on a page.
e.g.
"This is what I think"
- My Name, My Company
I'd imagine the quote should go in a blockquote. I've also seen some use of cite to shown where a quote comes from but the HTML reference seems to show that this should be used to give the URL of a web page that the quote comes from, not the name of the person.
Does anyone have any suggestions for how this should be marked up?
The "old" way:
I might be chiming in very late, but I think the following is the correct way to mark up a testimonial:
<figure>
<blockquote>
"This is what I think"
</blockquote>
<footer>
— <cite class="author">My Name</cite>, <cite class="company">My Company</cite>
</footer>
</figure>
Per the W3C spec:
...the citation is contained within the footer of a figure element, this groups and associates the information, about the quote, with the quote...
.
.
.
The figure element represents some flow content, optionally with a caption, that is self-contained (like a complete sentence)...
Update:
As #MCTaylor17 has pointed out, the best practice has changed in regards to citing a quote. Here's the new spec (as of December 2017): https://www.w3.org/TR/html52/textlevel-semantics.html#the-cite-element
Now the <cite> element is expected anywhere you would expect Phrasing Content. This means that it should go within a <p>, <blockquote>, etc.
Example 17 in the spec demonstrates using a <cite> within a <blockquote>:
<blockquote>"Money is the real cause of poverty,"
<footer>
<cite id="baseref">The Ragged-Trousered Philanthropists, page 89.</cite>
</footer>
</blockquote>
To apply this to your own quote:
<blockquote>
"This is what I think"
<footer>
— <cite class="author">My Name</cite>, <cite class="company">My Company</cite>
</footer>
</blockquote>
You are correct in your assumption that a quote is supposed to go into a blockquote element and that the cite attribute should be used for the URI. Personally I handle the author of the quote with a separate div or p at the bottom of the quote like so:
<blockquote cite="http://a.uri.com/">
<p>This is a really insightful sentence.</p>
<p class="quoteCite">Darko Z</p>
</blockquote>
Then I just use CSS to make it look nice. Pretty basic. You might want to go look at Microformats.org as well and search around for ideas.
Hope this helps
EDIT: Its late and it slipped my mind but you could also use the cite element
<blockquote cite="http://a.uri.com/">
<p>This is a really insightful sentence.</p>
<cite>Darko Z</cite>
</blockquote>
but im not a 100% sure how well its supported, to be honest
EDIT 2: According to the HTML 5 draft, cite shoudn't be an author name so for future proofing you probably shouldn't use cite for that purpose.
Things changed. I think a proper structure in this century should look like:
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
<footer>
<cite title="Source Title">
Bill Gates
</cite>
</footer>
</blockquote>
You may be interested in using the hReview format--Google is rumored to support it, and it's pretty much applicable to your situation, depending on whether you're only interested in the appearance, or whether you want to facilitate machine readability as well.
Following the Mozilla Developer API this is the correct way to mark up a testimonial:
<figure>
<blockquote>
"This is my testimonial"
</blockquote>
<figcaption>
— <cite class="author">My Name</cite>, <cite class="company">My Company</cite>
</figcaption>
</figure>
Here are two solutions based on the HTML Living Standard:
<blockquote>
<p>This is what I think</p>
</blockquote>
<p>- My Name, My Company</p>
<figure>
<blockquote>
<p>This is what I think</p>
</blockquote>
<figcaption>My Name, My Company</figcaption>
</figure>
As Darko Z. says in the edit of his answer you should not use <cite> for the author's name. This is because, according to the spec today, <cite> is for marking up the title of a work, not for naming the author. In WHATWG's own words:
The cite element represents the title of a work... A person's name is not the title of a work — even if people call that person a piece of work — and the element must therefore not be used to mark up people's names.
The spec also says, that "attribution for the quotation, if any, must be placed outside the blockquote element."
If you are asking how this should be marked up semantically, yes, use a block quote, and yes, the cite attribute is for URL's. As for presentation, you could use whatever you want and style it accordingly.
Visitors will never see the difference unless they look at the source code, and I can't imagine that it would affect SEO either.
HTML5 includes a <figcaption> tag. To whit:
<figure>
<blockquote cite="http://example.com/page">
Nevermore
</blockquote>
<figcaption>
The Raven
</figcaption>
</figure>
A lot of comments here suggesting to use the cite element for the name of the person who wrote the review.
The <cite> HTML element is used to describe a reference to a cited creative work, and must include the title of that work.
The Citation element
<!DOCTYPE html>
<blockquote>
<p>Quote
</blockquote>
<p>Author
would be the most correct.