{"id":137167,"date":"2024-10-14T15:33:08","date_gmt":"2024-10-14T10:03:08","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?page_id=137167"},"modified":"2024-10-16T17:07:38","modified_gmt":"2024-10-16T11:37:38","slug":"understanding-media-queries-within-svgs-svg","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/","title":{"rendered":"Understanding Media Queries within SVGs | SVG"},"content":{"rendered":"\n<p>While SVGs are inherently responsive due to their vector nature, you can further customize their behavior based on screen size and device capabilities using media queries.<\/p>\n\n\n\n<p><strong>Basic Syntax<\/strong><\/p>\n\n\n\n<p>HTML<\/p>\n\n\n\n<p>&lt;svg width=&#8221;100%&#8221; height=&#8221;100%&#8221; viewBox=&#8221;0 0 200 200&#8243;&gt;<\/p>\n\n\n\n<p>&nbsp; &lt;circle cx=&#8221;50&#8243; cy=&#8221;50&#8243; r=&#8221;25&#8243; fill=&#8221;blue&#8221; \/&gt;<\/p>\n\n\n\n<p>&lt;\/svg&gt;<\/p>\n\n\n\n<p>CSS<\/p>\n\n\n\n<p>@media only screen and (max-width: 600px) {<\/p>\n\n\n\n<p>&nbsp; svg circle {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; r: 20;<\/p>\n\n\n\n<p>&nbsp; }<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>In this example, the circle&#8217;s radius will be reduced to 20 pixels on screens narrower than 600px.<\/p>\n\n\n\n<p><strong>Key Considerations<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>viewBox attribute:<\/strong> The viewBox attribute on the &lt;svg&gt; element defines the coordinate system within the SVG. It&#8217;s essential for responsive design as it allows you to scale the SVG content relative to its dimensions.<\/li>\n\n\n\n<li><strong>Relative units:<\/strong> Use relative units like em or rem for dimensions within SVG elements to ensure they scale with the surrounding content.<\/li>\n\n\n\n<li><strong>CSS media queries:<\/strong> Use CSS media queries to target specific screen sizes and apply different styles to your SVG elements.<\/li>\n<\/ul>\n\n\n\n<p><strong>Additional Techniques<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Responsive SVG Sprites:<\/strong> Combine multiple SVGs into a single sprite and use CSS to display specific elements based on screen size.<\/li>\n\n\n\n<li><strong>SVG Animation:<\/strong> Use SMIL or JavaScript to create animations that adapt to different screen sizes.<\/li>\n\n\n\n<li><strong>SVG Filters:<\/strong> Apply filters to SVG elements to create visually interesting effects that can be adjusted based on screen size.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example: Responsive SVG Sprite<\/strong><\/p>\n\n\n\n<p>HTML<\/p>\n\n\n\n<p>&lt;svg width=&#8221;0&#8243; height=&#8221;0&#8243;&gt;<\/p>\n\n\n\n<p>&nbsp; &lt;symbol id=&#8221;icon-star&#8221;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;\/symbol&gt;<\/p>\n\n\n\n<p>&lt;\/svg&gt;<\/p>\n\n\n\n<p>&lt;svg width=&#8221;200&#8243; height=&#8221;100&#8243;&gt;<\/p>\n\n\n\n<p>&nbsp; &lt;use xlink:href=&#8221;#icon-star&#8221; x=&#8221;50&#8243; y=&#8221;50&#8243; \/&gt;<\/p>\n\n\n\n<p>&lt;\/svg&gt;<\/p>\n\n\n\n<p>CSS<\/p>\n\n\n\n<p>@media only screen and (max-width: 600px) {<\/p>\n\n\n\n<p>&nbsp; svg use {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; width: 20px;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; height: 20px;<\/p>\n\n\n\n<p>&nbsp; }<\/p>\n\n\n\n<p>} By understanding how to use media queries and other techniques with SVGs, you can create responsive and visually appealing designs that adapt to different screen sizes and devices.<\/p>\n\n\n\n<div class=\"wp-block-buttons alignwide is-content-justification-space-between is-layout-flex wp-container-core-buttons-is-layout-3d213aab wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button is-style-fill\"><a class=\"wp-block-button__link has-content-heading-color has-text-color has-background has-link-color wp-element-button\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/using-svgs-as-filters-svg\/\" style=\"background-color:#ffffff\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>&lt;&lt;Prev<\/strong><\/a><\/div>\n\n\n\n<div class=\"wp-block-button is-style-fill\"><a class=\"wp-block-button__link has-content-heading-color has-text-color has-background has-link-color wp-element-button\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/certificate-in-responsive-web-design\/\" style=\"background-color:#ffffff\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Back To The Tutorial<\/strong><\/a><\/div>\n\n\n\n<div class=\"wp-block-button is-style-fill\"><a class=\"wp-block-button__link has-content-heading-color has-text-color has-background has-link-color wp-element-button\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/optimizing-svgs-svg\/\" style=\"background-color:#ffffff\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Next&gt;&gt;<\/strong><\/a><\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>While SVGs are inherently responsive due to their vector nature, you can further customize their behavior based on screen size and device capabilities using media queries. Basic Syntax HTML &lt;svg width=&#8221;100%&#8221; height=&#8221;100%&#8221; viewBox=&#8221;0 0 200 200&#8243;&gt; &nbsp; &lt;circle cx=&#8221;50&#8243; cy=&#8221;50&#8243; r=&#8221;25&#8243; fill=&#8221;blue&#8221; \/&gt; &lt;\/svg&gt; CSS @media only screen and (max-width: 600px) { &nbsp; svg circle&#8230;<\/p>\n","protected":false},"author":15,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-137167","page","type-page","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Understanding Media Queries within SVGs | SVG - Tutorial<\/title>\n<meta name=\"description\" content=\"Ace the Certified Responsive Web Design exam on your first try with our expert preparation guide. Get Certified Now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding Media Queries within SVGs | SVG - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Ace the Certified Responsive Web Design exam on your first try with our expert preparation guide. Get Certified Now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-16T11:37:38+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/\",\"name\":\"Understanding Media Queries within SVGs | SVG - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2024-10-14T10:03:08+00:00\",\"dateModified\":\"2024-10-16T11:37:38+00:00\",\"description\":\"Ace the Certified Responsive Web Design exam on your first try with our expert preparation guide. Get Certified Now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Understanding Media Queries within SVGs | SVG\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Understanding Media Queries within SVGs | SVG - Tutorial","description":"Ace the Certified Responsive Web Design exam on your first try with our expert preparation guide. Get Certified Now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/","og_locale":"en_US","og_type":"article","og_title":"Understanding Media Queries within SVGs | SVG - Tutorial","og_description":"Ace the Certified Responsive Web Design exam on your first try with our expert preparation guide. Get Certified Now!","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-10-16T11:37:38+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/","name":"Understanding Media Queries within SVGs | SVG - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2024-10-14T10:03:08+00:00","dateModified":"2024-10-16T11:37:38+00:00","description":"Ace the Certified Responsive Web Design exam on your first try with our expert preparation guide. Get Certified Now!","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/understanding-media-queries-within-svgs-svg\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Understanding Media Queries within SVGs | SVG"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/137167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=137167"}],"version-history":[{"count":3,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/137167\/revisions"}],"predecessor-version":[{"id":137408,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/137167\/revisions\/137408"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=137167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=137167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=137167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}