Google + Meta Description + Line break = Possible?
Asked Answered
H

2

14

Is it possible to include line breaks in the description of a page shown in Google search results?

Heterograft answered 30/5, 2011 at 19:5 Comment(0)
M
9

No. You can't use html; and HTML ignores whitespace (when it's not used inside a text tag) so it doesn't matter if there's a space (\n\r,etc) or not; google parser will just grab the string, strip any bad code and place the text alone.

Take into consideration that Google will grab 150 characters from the description meta tag. You can test it here: http://www.javascriptkit.com/script/script2/charcount.shtml

Masturbation answered 30/5, 2011 at 19:6 Comment(4)
What a big pity, what do you thing about adding  's until google is forced to break the line? I just read it in another forum.Heterograft
That's a waste of your characters, and it probably won't work on all monitors.Farcy
Nbsps are html and will probably get stripped out anyhowJulide
-1; whether or not Google respects newlines in attributes, the general claim that "HTML ignores whitespace" is very much wrong. Runs of white space in text nodes typically get rendered as a single space (although even that behaviour can be changed via CSS!), but whitespace in HTML attributes is unambiguously not "ignored"; it's all preserved literally.Cavanaugh
C
4

No, it's impossible.

This shouldn't necessarily be obvious; literal newlines in HTML attributes are valid and meaningful (see https://mcmap.net/q/545627/-how-can-i-use-a-multiline-value-for-an-html-tag-attribute-i-e-how-do-i-escape-newline), and the HTML spec has nothing special to say forbidding them in <meta name="description" ... elements (see https://html.spec.whatwg.org/#meta-description), and Google even shows an example at https://support.google.com/webmasters/answer/35624?hl=en of this <meta> description including literal newlines:

<meta name="Description" content="Written by A.N. Author, 
Illustrated by V. Gogh, Price: $17.99, 
Length: 784 pages">

However, despite this, Google does not respect such newlines; any run of whitespace gets treated as a single space when showing the description in Google Search results. I did a quick experiment with a domain I control and a couple of other applications that respect <meta name="description" ...> elements - namely, Slack and Facebook - and found that they also behave in the same way, converting newlines I put into the description to spaces. At a glance, it appears to me that this is the unwritten standard.

Cavanaugh answered 22/4, 2019 at 11:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.