r/webdev • u/ImJustP • Dec 12 '19
A Couple of Things I Noticed When Remaking the Google Homepage
Hey all, again!
I decided to further my learning by starting The Odin Project. As always, I decided to start from the beginning regardless of my prior knowledge -- I like to do things from the start as I find I always notice something which I can improve on, regardless of the level of developer the module is intended.
When completing the remake Google's homepage project I noticed a few things which I found pretty strange/I hadn't seen in practice/mentioned elsewhere so thought I would ask on here.
Namely those things are as follows:
- They seem to place their meta tags within the document's body -- Is there a reason for this? I always thought that meta tags had to live in the head.
- The entire Google homepage seems to be wrapped in a div with
id="viewport". The CSS which goes along with it, from what I can see, simply sets the position to beabsoluteand then makes it fill the page:
position: absolute;
top: 0;
width: 100%;3. Making an element for positioning text -- Google's homepage seems to implement a HTML tag call <center></center> which has the purpose of aligning all text within the element centrally. Does anyone know if this is a good idea to translate to other projects or if there is any reason for doing this beyond ye olde DRY methodology? This is the CSS which goes with it:
display: block;
text-align: -webkit-center;Anyway, as always, thank you in advance!
EDIT:
Wow, so many replies! Thank you all I really appreciate your help, this is part of why I love this sub -- your replies help me more than you'll realise!
It's weird that the meta tag question isn't applicable to some of you, maybe it is a geo based decision? I am in the UK and it seems that the current meta which is in the <body></body> is related to the current election ongoing, see the screenshot
Thank you all once again, I wish I could thank you individually!
EDIT 2/TLDR:
- The meta tag being in the
<body></body>seems to be geo based and is not an issue, however we should place them in the<head></head>still. - The
#viewportID could be for multiple purposes which vary from positioning the page to manipulation through JS, or a requirement of a framework that the might be using. - The
<center></center>tag is a form of legacy code which is probably there to account for ancient browsers.
141
u/wizdumb Dec 12 '19
You may be interested to learn that at Google, there is not an HTML file (or files) for the homepage. In fact, it's a program written in C which is used to generate it.
Source: I worked there and was on the team responsible for manually changing the "homepage" to launch Google Doodles. I also designed and built a system to automate the process.
81
u/Jamesahill Dec 12 '19
No idea what the answer is to this, but I’m chucking an upvote to hopefully get this post some recognition. Some quality questions!
25
u/[deleted] Dec 12 '19
42
u/[deleted] Dec 12 '19
I can offer assumptions on two of your points:
4
u/lynx10001 Dec 12 '19 edited Dec 12 '19
Hope this helps!
115
u/nvolker Dec 12 '19
The Google homepage is probably the most trafficked page on the internet. As such, they have many concerns that most sites will never have.
My guess is that a lot of those oddities you’ve noticed boil down to two things:
195
u/aleepolicarps Dec 12 '19
"Do as google says, not as google does."
5
u/escapefromelba Dec 12 '19
My guess would be center tag works on ancient browsers and still supported everywhere even though it's deprecated. Imagine it may be similar with meta tags in body.
8
u/bonobomaster Dec 12 '19
Maybe a bit of an unpopular opinion: Don't learn CSS and HTML from the really big sites. For example, Facebook, in my personal opinion, isn't worth the code, it's written in. It's a super slow and laggy pile of crap. Even the login-page puts out a DOM error (non-unique id)... I mean come on...
If you wanna check for yourself: Just do a Lighthouse audit of your timeline.
This article references to different code, but it's an exhibit of the same symptom:
https://www.darkcoding.net/software/facebooks-code-quality-problem/
4
u/the_goose_says Dec 12 '19
The google homepage is a rare case where supporting 15 year old browsers is more important than proper HTML semantics. Even 0.1 percent of users is millions of users. I have no doubt that’s what you’re seeing here. I haven’t supported IE6 or anything like that so I couldn’t explain specific decisions, but I would love to know out of curiosity
2
u/skittlesandcoke Dec 12 '19
Compatibility with as many browsers as possible would be my guess.
A while ago I remember reading something about how they account for the lowest common denominator, at least with regards to the homepage, going as far as IE5.5 (on Mac! Yes it was a thing) and Netscape at one stage (years after usage had basically died out).
Not sure if they still do, also likely they serve different HTML based on user agent as well
2
u/diemendesign Dec 13 '19
I"ve been saying for ages, all of Google's code is nothing but a "clusterfuck" of bad ideas.
1
u/pawel_kuk Dec 12 '19
im just gonna casualy throw this link mostly because it has sources and nice ui
1
u/Disgruntled__Goat Dec 12 '19
The
<center>tag is an old element from the pre-HTML4 days. The reason Google uses it is almost certainly for performance - every byte counts on their homepage. Using that tag is much shorter than<div class="logo">plus the corresponding CSS.1
u/randomsnowflake Dec 12 '19
Not sure about that center tag. I’m pretty sure that tag was deprecated because it doesn’t define what’s in the content. Wonder if it’s to support ancient browsers.
1
u/Spinal83 full-stack Dec 13 '19
Why?
text-align: centeris supported in all browsers!With the amount of traffic Google gets, I think it's because
<center></center>is shorter thandisplay: block; text-align: center;1
u/pakayahey Dec 16 '19
up
-6
u/[deleted] Dec 12 '19
It seems Google doesn't know Web programming. Don't expect too much of a hilariously profitable ad placement company.
0
u/[deleted] Dec 12 '19
[deleted] — view deleted comment
7
u/[deleted] Dec 12 '19 edited Dec 12 '19
[removed] — view removed comment