{"id":72,"date":"2026-04-06T17:51:24","date_gmt":"2026-04-06T17:51:24","guid":{"rendered":"https:\/\/gigz.pk\/css\/?post_type=lesson&#038;p=72"},"modified":"2026-04-18T16:04:13","modified_gmt":"2026-04-18T16:04:13","slug":"css-units-training-content","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/","title":{"rendered":"CSS Units Training Content"},"content":{"rendered":"\n<p>CSS units are used to define sizes, spacing, and layout in web design. Understanding these units helps you create responsive and well-structured websites.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Pixel px<\/h3>\n\n\n\n<p>Pixels are fixed units. They represent a specific number of dots on the screen. This means the size will not change based on screen size.<\/p>\n\n\n\n<p>Example<br>font size 16px will always stay 16 pixels on any device<\/p>\n\n\n\n<p>Use px when you want precise control over size such as borders or small elements<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Percentage %<\/h3>\n\n\n\n<p>Percentage units are relative to the parent element. This means the size depends on the size of its container.<\/p>\n\n\n\n<p>Example<br>width 50 percent means the element will take half the width of its parent<\/p>\n\n\n\n<p>Use percentage for flexible layouts and responsive design<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">em<\/h3>\n\n\n\n<p>The em unit is relative to the font size of the parent element. It scales based on the surrounding text.<\/p>\n\n\n\n<p>Example<br>If parent font size is 16px then 2em equals 32px<\/p>\n\n\n\n<p>Use em for scalable spacing and typography but be careful as it can compound in nested elements<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">rem<\/h3>\n\n\n\n<p>The rem unit is relative to the root element which is usually the html tag. It provides more consistent sizing than em.<\/p>\n\n\n\n<p>Example<br>If root font size is 16px then 2rem equals 32px regardless of parent size<\/p>\n\n\n\n<p>Use rem for consistent and predictable layouts across the whole website<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">vh<\/h3>\n\n\n\n<p>Viewport height is based on the height of the browser window. One vh equals one percent of the viewport height<\/p>\n\n\n\n<p>Example<br>height 100vh makes an element take the full screen height<\/p>\n\n\n\n<p>Use vh for full screen sections and modern layouts<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">vw<\/h3>\n\n\n\n<p>Viewport width is based on the width of the browser window. One vw equals one percent of the viewport width<\/p>\n\n\n\n<p>Example<br>width 100vw makes an element span the full width of the screen<\/p>\n\n\n\n<p>Use vw for responsive widths and layouts that adapt to screen size<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Summary<\/h3>\n\n\n\n<p>Pixels are fixed and best for precise control<br>Percentage is relative to parent and good for flexible layouts<br>em is relative to parent font size and useful for scalable design<br>rem is relative to root and best for consistency<br>vh and vw are based on screen size and ideal for responsive design<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Practice Task<\/h3>\n\n\n\n<p>Create a simple webpage and apply different units to text boxes and sections. Try resizing the browser to see how each unit behaves.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/css\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">CSS Fundamentals (Beginner) > Selectors &#038; Properties > Units (px, %, em, rem, vh, vw)<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1776528219063\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1776528219340\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1776528218775\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n","protected":false},"menu_order":0,"template":"","class_list":["post-72","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CSS Units Training Content - CSS learning mastery<\/title>\n<meta name=\"description\" content=\"Learn CSS units px percent em rem vh vw with simple examples. Understand responsive sizing and choose the right unit for design.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS Units Training Content - CSS learning mastery\" \/>\n<meta property=\"og:description\" content=\"Learn CSS units px percent em rem vh vw with simple examples. Understand responsive sizing and choose the right unit for design.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/\" \/>\n<meta property=\"og:site_name\" content=\"CSS learning mastery\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-18T16:04:13+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\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\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/css-units-training-content\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/css-units-training-content\\\/\",\"name\":\"CSS Units Training Content - CSS learning mastery\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/#website\"},\"datePublished\":\"2026-04-06T17:51:24+00:00\",\"dateModified\":\"2026-04-18T16:04:13+00:00\",\"description\":\"Learn CSS units px percent em rem vh vw with simple examples. Understand responsive sizing and choose the right unit for design.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/css-units-training-content\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/css-units-training-content\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/css-units-training-content\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/css\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS Fundamentals (Beginner) > Selectors & Properties > Units (px, %, em, rem, vh, vw)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/css\\\/\",\"name\":\"CSS learning mastery\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/css\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSS Units Training Content - CSS learning mastery","description":"Learn CSS units px percent em rem vh vw with simple examples. Understand responsive sizing and choose the right unit for design.","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:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/","og_locale":"en_US","og_type":"article","og_title":"CSS Units Training Content - CSS learning mastery","og_description":"Learn CSS units px percent em rem vh vw with simple examples. Understand responsive sizing and choose the right unit for design.","og_url":"https:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/","og_site_name":"CSS learning mastery","article_modified_time":"2026-04-18T16:04:13+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/","url":"https:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/","name":"CSS Units Training Content - CSS learning mastery","isPartOf":{"@id":"https:\/\/gigz.pk\/css\/#website"},"datePublished":"2026-04-06T17:51:24+00:00","dateModified":"2026-04-18T16:04:13+00:00","description":"Learn CSS units px percent em rem vh vw with simple examples. Understand responsive sizing and choose the right unit for design.","breadcrumb":{"@id":"https:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/css\/lesson\/css-units-training-content\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/css\/"},{"@type":"ListItem","position":2,"name":"CSS Fundamentals (Beginner) > Selectors & Properties > Units (px, %, em, rem, vh, vw)"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/css\/#website","url":"https:\/\/gigz.pk\/css\/","name":"CSS learning mastery","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/css\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/lesson\/72","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/media?parent=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}