问题原文
原帖链接 · Richard Parnaby-King · CC BY-SA 3.0
TLDR;
Does Google care how code is formatted?
Background
I work in an agency. One developer is trying to convince the other to put line-breaks between rules in his css file:
.class {
width:100%;
height:auto;
}
as opposed to inline: .class { width:100%; height:auto; }
The argument is that it reduces the file-size, to which the counter-argument is "we're minifying the css" afterward.
The last argument is "Google cares about how code is formatted" and presented the following link https://google.github.io/styleguide/htmlcssguide.xml
We pointed out that one of the last points at the bottom of the page is that css rules must have line breaks in them:
Always put a blank line (two line breaks) between rules.
html {
background: #fff;
}
body {
margin: auto;
width: 50%;
}
Even with his own argument blown out of the water he is still adamant that Google cares about css, html etc being minified and inline.
Which leads to my question (looking for an authoritative answer - links to official Google website required) - Does Google care how code is formatted?
My personal answer is "No", otherwise Google wouldn't be telling us minifying our code to reduce load time on mobile devices etc.
社区高分解答
原帖链接 · Rob · CC BY-SA 3.0
That whole article is about making code readable for humans and has nothing to do with SEO.
Google does not care about formatting. Google only cares about content. Anything that helps outline that content, such as proper headings to show them where a new section begins and lists, will help them figure out what your content is about and where it begins and ends.
Every company and every person has their own style of writing code. Google does not dictate or suggest you change that but tries to give what they consider best practices or good ideas.
take a few minutes to look at the code around you and determine its style. If they use spaces around all their arithmetic operators, you should too.
You are free to ignore them or accept them as you wish.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
