W3c html meta viewport

Содержание
  1. HTML name Attribute
  2. Browser Support
  3. Syntax
  4. Attribute Values
  5. Responsive Web Design — The Viewport
  6. Setting The Viewport
  7. Size Content to The Viewport
  8. HTML Tag
  9. Browser Support
  10. Attributes
  11. Global Attributes
  12. More Examples
  13. HTML Responsive Web Design
  14. What is Responsive Web Design?
  15. Setting The Viewport
  16. Example
  17. Responsive Images
  18. Using the width Property
  19. Example
  20. Using the max-width Property
  21. Example
  22. Example
  23. Responsive Text Size
  24. Hello World
  25. Example
  26. Hello World Viewport is the browser window size. 1vw = 1% of viewport width. If the viewport is 50cm wide, 1vw is 0.5cm. Media Queries In addition to resize text and images, it is also common to use media queries in responsive web pages. With media queries you can define completely different styles for different browser sizes. Example: resize the browser window to see that the three div elements below will display horizontally on large screens and stack vertically on small screens: Example .main float: left; width: 60%; /* The width is 60%, by default */ > /* Use a media query to add a breakpoint at 800px: */ @media screen and (max-width: 800px) .left, .main, .right width: 100%; /* The width is 100%, when the viewport is 800px or smaller */ > > Tip: To learn more about Media Queries and Responsive Web Design, read our RWD Tutorial. Responsive Web Page — Full Example A responsive web page should look good on large desktop screens and on small mobile phones. Ever heard about W3Schools Spaces? Here you can create your website from scratch or use a template, and host it for free. Responsive Web Design — Frameworks All popular CSS Frameworks offer responsive design. They are free, and easy to use. W3.CSS W3.CSS is a modern CSS framework with support for desktop, tablet, and mobile design by default. W3.CSS is smaller and faster than similar CSS frameworks. W3.CSS is designed to be independent of jQuery or any other JavaScript library. W3.CSS Demo Resize the page to see the responsiveness! London London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants. Paris Paris is the capital of France. The Paris area is one of the largest population centers in Europe, with more than 12 million inhabitants. Tokyo Tokyo is the capital of Japan. It is the center of the Greater Tokyo Area, and the most populous metropolitan area in the world. Example W3Schools Demo Resize this responsive page!
London London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants. Paris Paris is the capital of France. The Paris area is one of the largest population centers in Europe, with more than 12 million inhabitants. Tokyo Tokyo is the capital of Japan. It is the center of the Greater Tokyo Area, and the most populous metropolitan area in the world. To learn more about W3.CSS, read our W3.CSS Tutorial. Bootstrap Another popular CSS framework is Bootstrap: Example My First Bootstrap Page Resize this responsive page to see the effect!
Column 1 Lorem ipsum. Column 2 Lorem ipsum. Column 3 Lorem ipsum.
To learn more about Bootstrap, go to our Bootstrap Tutorial. Источник
  • Media Queries
  • Example
  • Responsive Web Page — Full Example
  • Responsive Web Design — Frameworks
  • W3.CSS
  • W3.CSS Demo
  • London
  • Paris
  • Tokyo
  • Example
  • W3Schools Demo
  • London
  • Paris
  • Tokyo
  • Bootstrap
  • Example
  • My First Bootstrap Page
  • Column 1
  • Column 2
  • Column 3
  • HTML name Attribute

    Use the name attribute to define a description, keywords, and the author of an HTML document. Also define the viewport to control the page’s dimensions and scaling for different devices:

    The name attribute specifies the name for the metadata.

    The name attribute specifies a name for the information/value of the content attribute.

    Читайте также:  Сложность операций коллекции java

    Note: If the http-equiv attribute is set, the name attribute should not be set.

    HTML5 introduced a method to let web designers take control over the viewport (the user’s visible area of a web page), through the tag (See «Setting The Viewport» example below).

    Browser Support

    Syntax

    Attribute Values

    Value Description
    application-name Specifies the name of the Web application that the page represents
    author Specifies the name of the author of the document. Example:

    Tip: Always specify keywords (needed by search engines to catalogize the page). Example:

    The viewport varies with the device, and will be smaller on a mobile phone than on a computer screen.

    You should include the following viewport element in all your web pages:

    A viewport element gives the browser instructions on how to control the page’s dimensions and scaling.

    The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).

    The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.

    Here is an example of a web page without the viewport meta tag, and the same web page with the viewport meta tag:

    Tip: If you are browsing this page with a phone or a tablet, you can click on the two links below to see the difference.

    Источник

    Responsive Web Design — The Viewport

    The viewport is the user’s visible area of a web page.

    The viewport varies with the device, and will be smaller on a mobile phone than on a computer screen.

    Before tablets and mobile phones, web pages were designed only for computer screens, and it was common for web pages to have a static design and a fixed size.

    Then, when we started surfing the internet using tablets and mobile phones, fixed size web pages were too large to fit the viewport. To fix this, browsers on those devices scaled down the entire web page to fit the screen.

    This was not perfect!! But a quick fix.

    Setting The Viewport

    HTML5 introduced a method to let web designers take control over the viewport, through the tag.

    You should include the following viewport element in all your web pages:

    This gives the browser instructions on how to control the page’s dimensions and scaling.

    The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).

    The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.

    Here is an example of a web page without the viewport meta tag, and the same web page with the viewport meta tag:

    Tip: If you are browsing this page with a phone or a tablet, you can click on the two links above to see the difference.

    Size Content to The Viewport

    Users are used to scroll websites vertically on both desktop and mobile devices — but not horizontally!

    So, if the user is forced to scroll horizontally, or zoom out, to see the whole web page it results in a poor user experience.

    Some additional rules to follow:

    1. Do NOT use large fixed width elements — For example, if an image is displayed at a width wider than the viewport it can cause the viewport to scroll horizontally. Remember to adjust this content to fit within the width of the viewport.

    2. Do NOT let the content rely on a particular viewport width to render well — Since screen dimensions and width in CSS pixels vary widely between devices, content should not rely on a particular viewport width to render well.

    3. Use CSS media queries to apply different styling for small and large screens — Setting large absolute CSS widths for page elements will cause the element to be too wide for the viewport on a smaller device. Instead, consider using relative width values, such as width: 100%. Also, be careful of using large absolute positioning values. It may cause the element to fall outside the viewport on small devices.

    Источник

    HTML Tag

    The tag defines metadata about an HTML document. Metadata is data (information) about data.

    tags always go inside the element, and are typically used to specify character set, page description, keywords, author of the document, and viewport settings.

    Metadata will not be displayed on the page, but is machine parsable.

    Metadata is used by browsers (how to display content or reload page), search engines (keywords), and other web services.

    There is a method to let web designers take control over the viewport (the user’s visible area of a web page), through the tag (See «Setting The Viewport» example below).

    Browser Support

    Attributes

    Attribute Value Description
    charset character_set Specifies the character encoding for the HTML document
    content text Specifies the value associated with the http-equiv or name attribute
    http-equiv content-security-policy
    content-type
    default-style
    refresh
    Provides an HTTP header for the information/value of the content attribute
    name application-name
    author
    description
    generator
    keywords
    viewport
    Specifies a name for the metadata

    Global Attributes

    More Examples

    Define keywords for search engines:

    Источник

    HTML Responsive Web Design

    Responsive web design is about creating web pages that look good on all devices!

    A responsive web design will automatically adjust for different screen sizes and viewports.

    Responsive Web Design

    What is Responsive Web Design?

    Responsive Web Design is about using HTML and CSS to automatically resize, hide, shrink, or enlarge, a website, to make it look good on all devices (desktops, tablets, and phones):

    Setting The Viewport

    To create a responsive website, add the following tag to all your web pages:

    Example

    This will set the viewport of your page, which will give the browser instructions on how to control the page’s dimensions and scaling.

    Here is an example of a web page without the viewport meta tag, and the same web page with the viewport meta tag:

    Without the viewport meta tag:

    With the viewport meta tag:

    Tip: If you are browsing this page on a phone or a tablet, you can click on the two links above to see the difference.

    Responsive Images

    Responsive images are images that scale nicely to fit any browser size.

    Using the width Property

    If the CSS width property is set to 100%, the image will be responsive and scale up and down:

    Example

    style=»width:100%;»>

    Notice that in the example above, the image can be scaled up to be larger than its original size. A better solution, in many cases, will be to use the max-width property instead.

    Using the max-width Property

    If the max-width property is set to 100%, the image will scale down if it has to, but never scale up to be larger than its original size:

    Example

    Flowers

    Responsive Text Size

    The text size can be set with a «vw» unit, which means the «viewport width».

    That way the text size will follow the size of the browser window:

    Hello World

    Resize the browser window to see how the text size scales.

    Example

    Hello World

    Viewport is the browser window size. 1vw = 1% of viewport width. If the viewport is 50cm wide, 1vw is 0.5cm.

    Media Queries

    In addition to resize text and images, it is also common to use media queries in responsive web pages.

    With media queries you can define completely different styles for different browser sizes.

    Example: resize the browser window to see that the three div elements below will display horizontally on large screens and stack vertically on small screens:

    Example

    .main float: left;
    width: 60%; /* The width is 60%, by default */
    >

    /* Use a media query to add a breakpoint at 800px: */
    @media screen and (max-width: 800px) .left, .main, .right width: 100%; /* The width is 100%, when the viewport is 800px or smaller */
    >
    >

    Tip: To learn more about Media Queries and Responsive Web Design, read our RWD Tutorial.

    Responsive Web Page — Full Example

    A responsive web page should look good on large desktop screens and on small mobile phones.

    Ever heard about W3Schools Spaces? Here you can create your website from scratch or use a template, and host it for free.

    Responsive Web Design — Frameworks

    All popular CSS Frameworks offer responsive design.

    They are free, and easy to use.

    W3.CSS

    W3.CSS is a modern CSS framework with support for desktop, tablet, and mobile design by default.

    W3.CSS is smaller and faster than similar CSS frameworks.

    W3.CSS is designed to be independent of jQuery or any other JavaScript library.

    W3.CSS Demo

    Resize the page to see the responsiveness!

    London

    London is the capital city of England.

    It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.

    Paris

    Paris is the capital of France.

    The Paris area is one of the largest population centers in Europe, with more than 12 million inhabitants.

    Tokyo

    Tokyo is the capital of Japan.

    It is the center of the Greater Tokyo Area, and the most populous metropolitan area in the world.

    Example

    W3Schools Demo

    Resize this responsive page!

    London

    London is the capital city of England.

    It is the most populous city in the United Kingdom,
    with a metropolitan area of over 13 million inhabitants.

    Paris

    Paris is the capital of France.

    The Paris area is one of the largest population centers in Europe,
    with more than 12 million inhabitants.

    Tokyo

    Tokyo is the capital of Japan.

    It is the center of the Greater Tokyo Area,
    and the most populous metropolitan area in the world.

    To learn more about W3.CSS, read our W3.CSS Tutorial.

    Bootstrap

    Another popular CSS framework is Bootstrap:

    Example

    My First Bootstrap Page

    Resize this responsive page to see the effect!

    Column 1

    Lorem ipsum.

    Column 2

    Lorem ipsum.

    Column 3

    Lorem ipsum.

    To learn more about Bootstrap, go to our Bootstrap Tutorial.

    Источник

    Оцените статью