Home >Web Front-end >H5 Tutorial >The magical effect of mobile html5 meta tag_html5 tutorial skills

The magical effect of mobile html5 meta tag_html5 tutorial skills

WBOY
WBOYOriginal
2016-05-16 15:46:141803browse

When making a mobile website, in addition to the simplicity of the page and easy operation, etc., which visitors can see, it is the setting of Meta tags. Properly setting Meta tags will improve the search engine optimization of the mobile website and the rendering of mobile browsers. Displays are very helpful. Everyone is very familiar with the meta tag in the web layout of the desktop platform. It is always located inside the head element. Friends who do SEO must have a special feeling for meta. Today we will talk about the meta tag of the mobile platform. What are the magical effects of meta tags on mobile platforms?
1. Viewport of Meta
When it comes to mobile platform meta tags, we have to talk about viewport. So what is viewport?
Viewport is the visual area. For desktop browsers, viewport refers to the area used to view web pages after removing all toolbars, status bars, scroll bars, etc.
. For traditional WEB pages, it is normal for the width of 980 to be displayed on the iPhone, and it also fills the screen. But for webapps, it may be a bit of a problem. On iPhones, our webapps usually have a width of 100cm in portrait mode. 320, what effect will our 320 page display on the iPhone? Some people may think that the iPhone is not 320mm wide, it should fill the screen, right? What is the reality? Let’s take a look at how the following layout appears on the iPhone

Copy the code
The code is as follows:





Meta Viewport</title> ; <br /><style type="text/css"> <br>div,body{ <br>padding:0; <br>margin:0; <br>} <br>body{ <br>padding -top:100px; <br>color:#fff; <br>} <br>div{ <br>width:320px; <br>height:100px; <br>margin:0 auto; <br>background:# 000; <br>text-align:center; <br>font:30px/100px Arial; <br>} <br></style> <br></head> <br><body> <br><div> <br>AppUE <br></div> <br></body> <br></html> <br> </div> <br><strong>So we have to change the viewport , we have the following attribute values ​​​​that can be set: <br></strong>width: the width of the viewport (ranging from 200 to 10,000, the default is 980 pixels) <br>height: the height of the viewport (ranging from 223 to 10,000) <br>initial-scale: initial scaling (ranging from >0 to 10) <br>minimum-scale: the minimum scale the user is allowed to zoom to<br>maximum-scale: the maximum scale the user is allowed to zoom to<br>user-scalable: Whether the user can manually zoom<br>For these attributes, we can set one or more of them. You do not need to set them all at the same time. The iPhone will automatically calculate other attribute values ​​​​based on the attributes you set, instead of Just use the default value. <br>If you set initial-scale=1, then width and height will automatically be 320*356 in portrait mode (not 320*480 because the address bar etc. all occupy space), and 480*208 in landscape mode. Similarly, if you only set width, initial-scale and height will be automatically calculated. For example, if you set width=320, the initial-scale is 1 when the screen is in portrait mode, and becomes 1.5 when the screen is in landscape orientation. So how do these settings let Safari know? In fact, it is very simple, just a meta, in the form: <br><br><div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode49'));"><u>Copy the code</u></span></div>The code is as follows:</div> <div class="msgborder" id="phpcode49"> <br><meta name=”viewport” content=”width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;” /> <br> </div> <p>Okay, we can lay out our page in full screen, no longer need to worry about the page being displayed very small! <br><strong><font color="#0000ff">2. Meta format-detection <br></font></strong><br></p> <div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode50'));"><u>Copy code</u></span></div>The code is as follows:</div> <div class="msgborder" id="phpcode50"> <br><meta name=”format-detection” content=”telephone=no” /> <br> </div> <p>You clearly wrote a string of numbers without adding a link style, but the iPhone will automatically add a link style to your text, and clicking on the number will automatically dial the number! How to remove this dial-up link? At this time, our meta should show its magic again. The code is as follows: <br>telephone=no prohibits converting numbers into dial-up links! <br>telephone=yes enables the conversion of numbers into dial-up links. To enable the conversion function, there is no need to write this meta. It is enabled by default! <br><br><strong><font color="#0000ff">3. Meta of apple-mobile-web-app-capable <br></font></strong><meta name=”apple-mobile-web-app-capable” content=”yes” /> <br>The function of this meta is to delete the default Apple toolbar and menu bar. content has two values ​​"yes" and "no". When we need to display the toolbar and menu bar, there is no need to add this line of meta. The default is to display it. <br><strong><font color="#0000ff">4. Meta of apple-mobile-web-app-status-bar-style <br></font></strong><br></p> <div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode51'));"><u> Copy the code</u></span></div>The code is as follows:</div> <div class="msgborder" id="phpcode51"> <br><meta name=”apple-mobile-web-app-status-bar-style” content=”default” /> ; <br /><meta name=”apple-mobile-web-app-status-bar-style” content=”black” /> <br><meta name=”apple-mobile-web-app-status -bar-style” content=”black-translucent” /> <br> </div> <p>The function is to control the status bar display style<br><br></p> <div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode52'));"><u>Copy the code</u></span></div>The code is as follows:</div> <div class="msgborder" id="phpcode52"> <br>status-bar-style:black <br>status-bar-style:black-translucent <br> </div> <br><font color="#ff0000">Today I will briefly talk about which Meta tags need to be added to the mobile version of the website: </font> <br><strong><font color="#0000ff">viewport</font></strong> <br>viewport is almost a recognized standard. It was originally created by Apple for the mobile version of Safari on the iPhone. Due to the Big seller, accepted by most other mobile browsers, such as Opera Mobile, iPhone, Android, Iris, IE, BlackBerry, Obigo, Firefox <br>The most basic example, making the site full screen width on mobile: <br><strong><font color="#0000ff"><br><div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode53'));"><u>Copy code</u></span></div>The code is as follows:</div> <div class="msgborder" id="phpcode53"> <br><meta name="viewport" content="width=device-width, initial-scale=1.0"/> <br> </div>HandheldFriendly <br></font></strong>This label and MobileOptimized introduced below are de facto labels in the feature machine era. The <br>HandheldFriendly tag was first used to mark mobile content in AvantGo browsing, and later became a universal standard for marking mobile sites, but the support of this tag is unknown. <br><br><div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode54'));"><u>Copy code</u></span></div>The code is as follows:</div> <div class="msgborder" id="phpcode54"> <br><meta name="HandheldFriendly" content ="true"/> <br> </div> <p><strong><font color="#0000ff">MobileOptimized </font></strong><br>This is a Windows-specific meta tag that eventually became another method for identifying mobile content, but the disadvantage of this tag is that it is The width must be given, and again, the support of this tag is unknown: <br><br></p> <div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode55'));"><u>Copy the code</u></span></div>The code is as follows:</div> <div class="msgborder" id="phpcode55"> <br><meta name="MobileOptimized" content="320"/><br> </div></div><div class="nphpQianMsg"><div class="clear"></div></div><div class="nphpQianSheng"><span>Statement:</span><div>The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn</div></div></div><div class="nphpSytBox"><span>Previous article:<a class="dBlack" title="Implementing folding menu based on HTML5 code with source code download_html5 tutorial skills" href="https://m.php.cn/faq/5704.html">Implementing folding menu based on HTML5 code with source code download_html5 tutorial skills</a></span><span>Next article:<a class="dBlack" title="Implementing folding menu based on HTML5 code with source code download_html5 tutorial skills" href="https://m.php.cn/faq/5709.html">Implementing folding menu based on HTML5 code with source code download_html5 tutorial skills</a></span></div><div class="nphpSytBox2"><div class="nphpZbktTitle"><h2>Related articles</h2><em><a href="https://m.php.cn/article.html" class="bBlack"><i>See more</i><b></b></a></em><div class="clear"></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-6t+ed+2i-1n-4w" data-ad-client="ca-pub-5902227090019525" data-ad-slot="8966999616"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><ul class="nphpXgwzList"><li><b></b><a href="https://m.php.cn/faq/348281.html" title="AlloyTouch full-screen scrolling plug-in creates a smooth H5 page in 30 seconds" class="aBlack">AlloyTouch full-screen scrolling plug-in creates a smooth H5 page in 30 seconds</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/348372.html" title="HTML5 actual combat and analysis of touch events (touchstart, touchmove and touchend)" class="aBlack">HTML5 actual combat and analysis of touch events (touchstart, touchmove and touchend)</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/348373.html" title="Detailed explanation of image drawing examples in HTML5 canvas 9" class="aBlack">Detailed explanation of image drawing examples in HTML5 canvas 9</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/348374.html" title="Regular expressions and new HTML5 elements" class="aBlack">Regular expressions and new HTML5 elements</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/348469.html" title="How to combine NodeJS and HTML5 to drag and drop multiple files to upload to the server" class="aBlack">How to combine NodeJS and HTML5 to drag and drop multiple files to upload to the server</a><div class="clear"></div></li></ul></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="5027754603"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><footer><div class="footer"><div class="footertop"><img src="/static/imghwm/logo.png" alt=""><p>Public welfare online PHP training,Help PHP learners grow quickly!</p></div><div class="footermid"><a href="https://m.php.cn/about/us.html">About us</a><a href="https://m.php.cn/about/disclaimer.html">Disclaimer</a><a href="https://m.php.cn/update/article_0_1.html">Sitemap</a></div><div class="footerbottom"><p> © php.cn All rights reserved </p></div></div></footer><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></div><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><script>jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if( this.length ){ //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function() { if(!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if( _self.length ) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } $("table.syntaxhighlighter").wait(function() { $('table.syntaxhighlighter').append("<p class='cnblogs_code_footer'><span class='cnblogs_code_footer_icon'></span></p>"); }); $(document).on("click", ".cnblogs_code_footer",function(){ $(this).parents('table.syntaxhighlighter').css('display','inline-table');$(this).hide(); }); $('.nphpQianCont').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}}); </script></body><!-- Matomo --><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="https://tongji.php.cn/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '9']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!-- End Matomo Code --></html>