官术网_书友最值得收藏!

Meta tags and favicons

Our application will be mobile-first, as we have already discussed. To ensure that our HTML is fully optimized, let's add a bit more markup.

First, let's add a DOCTYPE declaration to the top of index.html. This tells the browser what kind of document to expect. In HTML 5 (the newest version of HTML), it always looks like this:

<!DOCTYPE html>

Next, we need to add a meta tag for viewport width. It looks like this:

<meta name="viewport" content="width=device-width, initial-scale=1">

What does this do? Essentially, it tells the browser to display the web page at the same width as its screen. So, if the web page seems to be 960px and our device is 320px wide, rather than zooming out and showing the whole page, it'll instead squish all the content down until it's 320px.

As you might expect, this is only a good idea if your website is responsive and able to adapt to a smaller size. However, since responsiveness is one of our main goals, let's do this from the start. Add this tag within the <head> of our document.

A couple more tags to go! The character set we use on our web page can be encoded in a couple of different ways: Unicode and ISO-8859-1. You can look up these encodings for more information, but long story short, we're using Unicode. Let's add it like so, right below the previous <meta> tag:

<meta charset="utf-8">

While we're at it, let's add the language the HTML is in. On our existing <html> tag, add lang="en":

<html lang="en">

Okay, that about does it for HTML housekeeping. The last thing we need is a favicon, the little icon displayed next to the title in the browser tab. This is included in our assets bundle, so all we have to do is link it up (right underneath our <meta> tags):

<link rel="shortcut icon" href="assets/favicon.ico" type="image/x-icon">

Your browser tab should now look like this:

With that, we're done!

Next, we'll look at how we will include React in our project, and all the other dependencies we will need.

主站蜘蛛池模板: 塔城市| 湖南省| 重庆市| 临泉县| 涡阳县| 宜丰县| 互助| 冷水江市| 宾阳县| 平和县| 平湖市| 游戏| 拜城县| 云安县| 喜德县| 勃利县| 达孜县| 广东省| 南投县| 盖州市| 余庆县| 榕江县| 抚顺县| 武城县| 瓮安县| 丰镇市| 巨野县| 黄平县| 白朗县| 定边县| 碌曲县| 噶尔县| 峨眉山市| 奇台县| 宜兰县| 永善县| 福鼎市| 兖州市| 濉溪县| 崇明县| 乌海市|