{"id":42673,"date":"2024-02-27T18:18:05","date_gmt":"2024-02-27T12:48:05","guid":{"rendered":"https:\/\/www.guvi.in\/blog\/?p=42673"},"modified":"2026-09-29T19:40:50","modified_gmt":"2026-09-29T14:10:50","slug":"complete-css-tutorial","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/complete-css-tutorial\/","title":{"rendered":"Complete CSS Tutorial: Core Concepts in a Nutshell"},"content":{"rendered":"\n<p>Every website you admire, from a clean portfolio to a busy online store, gets its look from CSS. It decides the colors, the spacing, the fonts, and how a page rearranges itself on your phone.<\/p>\n\n\n\n<p>This guide skips the long theory and covers the parts of CSS you will use most often. Go through the sections in order and try each example yourself, and you will have a solid base to build on.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>TL;DR Summary<\/strong><\/h2>\n\n\n\n<ul>\n<li>This CSS Tutorial covers the core building blocks: what CSS is, how to add it to a page, and how selectors and syntax work.<\/li>\n\n\n\n<li>You will see how to style colors, backgrounds, text, and fonts with short, practical examples.<\/li>\n\n\n\n<li>The box model, display, and positioning sections explain how elements take up space and where they sit on a page.<\/li>\n\n\n\n<li>Flexbox and CSS Grid are introduced at a basic level so you can understand how modern layouts are built.<\/li>\n\n\n\n<li>The final section shows how media queries help a page adjust to different screen sizes.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<div style=\"background-color: #099f4e; border: 3px solid #110053; border-radius: 12px; padding: 18px 22px; color: #FFFFFF; font-size: 18px; font-family: Montserrat, Helvetica, sans-serif; line-height: 1.6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); max-width: 750px;\">\n  <strong style=\"font-size: 22px; color: #ffffff;\">\ud83d\udca1 Did You Know?<\/strong>\n  <br \/><br \/>\n  <span><strong style=\"color: #110053;\">CSS<\/strong> was first proposed by <strong style=\"color: #110053;\">H\u00e5kon Wium Lie <\/strong>in <strong style=\"color: #110053;\">1994<\/strong> to make it easier to style and control the appearance of web pages.<\/span>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is CSS?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"628\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/09\/What-is-CSS-2-1200x628.webp\" alt=\"\" class=\"wp-image-141498\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/09\/What-is-CSS-2-1200x628.webp 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/09\/What-is-CSS-2-300x157.webp 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/09\/What-is-CSS-2-768x402.webp 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/09\/What-is-CSS-2-1536x803.webp 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/09\/What-is-CSS-2-150x78.webp 150w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/09\/What-is-CSS-2.webp 1734w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<p>CSS <em>(Cascading Style Sheets)<\/em> is the language that controls how a web page appears. <a href=\"https:\/\/www.guvi.in\/blog\/html-tutorial-guide-for-web-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">HTML<\/a> builds the structure of a page, such as headings, paragraphs, images, and buttons, and CSS decides how those elements appear on screen, including their colors, fonts, spacing, and layout.<\/p>\n\n\n\n<p>The word &#8220;cascading&#8221; refers to how the browser settles conflicts. When several rules target the same element, the browser picks a winner based on order, specificity, and importance. Generally, a later rule overrides an earlier one, and a more specific selector beats a general one.<\/p>\n\n\n\n<p>In web development, CSS works alongside HTML and <a href=\"https:\/\/www.guvi.in\/hub\/javascript\/what-is-javascript\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=complete-css-tutorial\" target=\"_blank\" rel=\"noreferrer noopener\">JavaScript<\/a>. HTML holds the content, CSS handles the design, and JavaScript adds behavior. Keeping design in CSS also means you can change an entire site&#8217;s look by editing one file instead of touching every page.<\/p>\n\n\n\n<p><strong>Key features of CSS:<\/strong><\/p>\n\n\n\n<ul>\n<li>Separates design from content<\/li>\n\n\n\n<li>Reuses one stylesheet across many pages<\/li>\n\n\n\n<li>Controls colors, fonts, and spacing<\/li>\n\n\n\n<li>Builds layouts for different screen sizes<\/li>\n\n\n\n<li>Lets rules cascade so styles stay predictable<\/li>\n<\/ul>\n\n\n\n<p><strong>Also Read:<\/strong> <em><a href=\"https:\/\/www.guvi.in\/blog\/a-complete-guide-to-html-and-css-for-beginners\/\" target=\"_blank\" rel=\"noreferrer noopener\">A Complete Guide to HTML and CSS for Beginners<\/a><\/em><\/p>\n\n\n\n<p><strong><em>Ready to build a career in software? HCL GUVI&#8217;s <\/em><\/strong><em><a href=\"https:\/\/www.guvi.in\/zen-class\/full-stack-development-course\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=complete-css-tutorial\" target=\"_blank\" rel=\"noreferrer noopener\">Software and AI Engineer Programme<\/a><\/em><strong><em> offers Full Stack and Backend tracks, 130+ hours of live classes, real-world projects, one-on-one mock interviews, and an IITM Pravartak certification. Modules are available in English, Tamil, Hindi, and Telugu. Explore the programme and apply today!<\/em><\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Ways to Add CSS (Inline, Internal, External)<\/strong><\/h2>\n\n\n\n<p>There are three ways to connect CSS to an HTML page. All three produce the same visual result, but they differ in how easy they are to manage as a project grows.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Inline CSS<\/strong><\/h3>\n\n\n\n<p>Inline CSS is written directly inside an HTML tag using the <code>style<\/code> attribute.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;h1 style=\"color: blue; font-size: 32px;\"&gt;Hello, CSS&lt;\/h1&gt;<\/code><\/pre>\n\n\n\n<ul>\n<li><code>style<\/code> is an HTML attribute that accepts CSS declarations.<\/li>\n\n\n\n<li><code>color: blue;<\/code> changes the text color of this one heading.<\/li>\n\n\n\n<li><code>font-size: 32px;<\/code> sets the text size to 32 pixels.<\/li>\n\n\n\n<li>Only this single <code>&lt;h1&gt;<\/code> is affected. No other heading on the page changes.<\/li>\n<\/ul>\n\n\n\n<p>Inline styles are handy for a quick test, but they mix design into your HTML and cannot be reused. Repeating them across many elements gets messy fast.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Internal CSS<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/www.guvi.in\/blog\/internal-css-in-html\/\" target=\"_blank\" rel=\"noreferrer noopener\">Internal CSS<\/a> goes inside a <code>&lt;style&gt;<\/code> tag, placed in the <code>&lt;head&gt;<\/code> of the HTML document.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;head&gt;\n  &lt;style&gt;\n    p {\n      color: darkgreen;\n      line-height: 1.6;\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;<\/code><\/pre>\n\n\n\n<ul>\n<li>The <code>&lt;style&gt;<\/code> tag tells the browser that everything inside it is CSS.<\/li>\n\n\n\n<li><code>p<\/code> is a selector, so the rules apply to every paragraph on this page.<\/li>\n\n\n\n<li><code>color: darkgreen;<\/code> changes the text color of all paragraphs.<\/li>\n\n\n\n<li><code>line-height: 1.6;<\/code> adds comfortable spacing between lines.<\/li>\n<\/ul>\n\n\n\n<p>This works well for a single page, but the styles stay locked inside that one file. A second page would need the same code copied into it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. External CSS<\/strong><\/h3>\n\n\n\n<p>External CSS lives in a separate <code>.css<\/code> file, which you connect to the HTML with a <code>&lt;link&gt;<\/code> tag.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;head&gt;\n  &lt;link rel=\"stylesheet\" href=\"styles.css\"&gt;\n&lt;\/head&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* styles.css *\/\nbody {\n  font-family: Arial, sans-serif;\n  background-color: #f5f5f5;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>rel=\"stylesheet\"<\/code> tells the browser the linked file is a stylesheet.<\/li>\n\n\n\n<li><code>href=\"styles.css\"<\/code> is the path to the file. If the file sits in a folder, the path changes, for example <code>css\/styles.css<\/code>.<\/li>\n\n\n\n<li>Inside <code>styles.css<\/code>, the <code>body<\/code> rules apply to the whole visible page.<\/li>\n\n\n\n<li>Any page that includes the same <code>&lt;link&gt;<\/code> tag gets the same styling.<\/li>\n<\/ul>\n\n\n\n<p>External CSS is the standard choice for real websites. One file can control the design of an entire site, and browsers can store it after the first visit, which helps pages load faster.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Which One Should You Use?<\/strong><\/h3>\n\n\n\n<p>Use external CSS for almost everything. Internal CSS is fine for small demos or single-page experiments, and inline CSS is best kept for quick tests or special cases.<\/p>\n\n\n\n<p>If the same property is set in more than one place, the browser follows the cascade. Inline styles generally win over internal and external ones, and between internal and external, the rule that appears later in the page wins when the selectors are equally specific.<\/p>\n\n\n\n<p><strong>Optional Read:<\/strong> <em><a href=\"https:\/\/www.guvi.in\/blog\/types-of-css-with-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\">Types of CSS<\/a><\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>CSS Syntax and Selectors<\/strong><\/h2>\n\n\n\n<p>Every CSS rule follows the same pattern. Once you can read one rule, you can read them all.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>h2 {\n  color: crimson;\n  margin-bottom: 12px;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>h2<\/code> is the <strong>selector<\/strong>. It chooses which elements the rule applies to.<\/li>\n\n\n\n<li>The curly braces <code>{ }<\/code> wrap the <strong>declaration block<\/strong>.<\/li>\n\n\n\n<li><code>color<\/code> and <code>margin-bottom<\/code> are <strong>properties<\/strong>, the things you want to change.<\/li>\n\n\n\n<li><code>crimson<\/code> and <code>12px<\/code> are <strong>values<\/strong>, what you want those properties to become.<\/li>\n\n\n\n<li>Each declaration ends with a semicolon.<\/li>\n<\/ul>\n\n\n\n<p>A property and its value together are called a declaration. A selector with its declaration block is called a rule.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Element Selector<\/strong><\/h3>\n\n\n\n<p>An element selector targets every instance of an HTML tag.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p {\n  font-size: 18px;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li>Every <code>&lt;p&gt;<\/code> on the page now has 18px text.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Class Selector<\/strong><\/h3>\n\n\n\n<p>A class selector targets any element that has a matching <code>class<\/code> attribute. It starts with a dot.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;p class=\"highlight\"&gt;Important note&lt;\/p&gt;\n&lt;p&gt;Regular note&lt;\/p&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>.highlight {\n  background-color: yellow;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>.highlight<\/code> matches elements with <code>class=\"highlight\"<\/code>.<\/li>\n\n\n\n<li>Only the first paragraph gets the yellow background.<\/li>\n\n\n\n<li>You can reuse the same class on as many elements as you like.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. ID Selector<\/strong><\/h3>\n\n\n\n<p>An ID selector targets one specific element. It starts with a hash symbol.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div id=\"main-header\"&gt;Welcome&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#main-header {\n  text-align: center;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>#main-header<\/code> matches the element with <code>id=\"main-header\"<\/code>.<\/li>\n\n\n\n<li>An ID should be used only once per page.<\/li>\n\n\n\n<li>In practice, classes are preferred for styling because they are easier to reuse.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Grouping and Descendant Selectors<\/strong><\/h3>\n\n\n\n<p>You can style several selectors at once by separating them with commas. You can also target elements inside other elements by separating selectors with a space.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>h1, h2, h3 {\n  font-family: Georgia, serif;\n}\n\nnav a {\n  text-decoration: none;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li>The first rule applies the same font to all three heading levels.<\/li>\n\n\n\n<li><code>nav a<\/code> matches only links that sit inside a <code>&lt;nav&gt;<\/code> element.<\/li>\n\n\n\n<li>Links outside the navigation keep their default underline.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Pseudo-class Selectors<\/strong><\/h3>\n\n\n\n<p>A pseudo-class applies styles when an element is in a particular state.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>button:hover {\n  background-color: black;\n  color: white;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>:hover<\/code> activates when the mouse pointer is over the element.<\/li>\n\n\n\n<li>The button turns black with white text only while it is hovered.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Which Rule Wins?<\/strong><\/h3>\n\n\n\n<p>When two rules conflict, the browser looks at specificity. An ID selector is stronger than a class selector, and a class selector is stronger than an element selector. If two rules have the same specificity, the later one wins.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Colors and Backgrounds<\/strong><\/h2>\n\n\n\n<p>Color is one of the first things you will change in any project. CSS gives you several ways to write colors, and you can use them for text, borders, and backgrounds.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Color Formats<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>.box-one {\n  color: tomato;\n}\n\n.box-two {\n  color: #2a9d8f;\n}\n\n.box-three {\n  color: rgb(38, 70, 83);\n}\n\n.box-four {\n  color: rgba(38, 70, 83, 0.5);\n}\n\n.box-five {\n  color: hsl(200, 60%, 40%);\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>tomato<\/code> is a named color. CSS has around 140 of these, which are easy to read but limited.<\/li>\n\n\n\n<li><code>#2a9d8f<\/code> is a HEX value. The pairs of characters represent red, green, and blue.<\/li>\n\n\n\n<li><code>rgb(38, 70, 83)<\/code> sets the same three channels using numbers from 0 to 255.<\/li>\n\n\n\n<li><code>rgba(38, 70, 83, 0.5)<\/code> adds an alpha value for transparency. <code>0<\/code> is fully transparent and <code>1<\/code> is fully solid.<\/li>\n\n\n\n<li><code>hsl(200, 60%, 40%)<\/code> describes color by hue (0 to 360 on the color wheel), saturation, and lightness. It is often the easiest format for making a lighter or darker version of a color.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Background Color and Image<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>.hero {\n  background-color: #1d3557;\n  background-image: url(\"hero.jpg\");\n  background-size: cover;\n  background-position: center;\n  background-repeat: no-repeat;\n  color: white;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>background-color<\/code> sets a solid color, which also acts as a fallback if the image fails to load.<\/li>\n\n\n\n<li><code>background-image: url(\"hero.jpg\");<\/code> places an image behind the content.<\/li>\n\n\n\n<li><code>background-size: cover;<\/code> scales the image to fill the whole element, cropping the edges if needed.<\/li>\n\n\n\n<li><code>background-position: center;<\/code> keeps the middle of the image in view.<\/li>\n\n\n\n<li><code>background-repeat: no-repeat;<\/code> stops the image from tiling.<\/li>\n\n\n\n<li><code>color: white;<\/code> keeps the text readable on top of a dark background.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Gradients<\/strong><\/h3>\n\n\n\n<p>A gradient is treated as a background image, so it goes in <code>background<\/code> or <code>background-image<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.banner {\n  background: linear-gradient(to right, #ff9a9e, #fad0c4);\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>linear-gradient<\/code> blends from one color to another in a straight line.<\/li>\n\n\n\n<li><code>to right<\/code> sets the direction, starting on the left and ending on the right.<\/li>\n\n\n\n<li>The two colors after it are the start and end points of the blend.<\/li>\n<\/ul>\n\n\n\n<p>Always check that your text color has enough contrast against the background. Light gray text on a white background looks stylish in a mockup but is hard for many people to read.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Text and Font Styling<\/strong><\/h2>\n\n\n\n<p>Most web pages are mainly text, so a few well-chosen text properties can change how a page feels.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>body {\n  font-family: \"Segoe UI\", Arial, sans-serif;\n  font-size: 16px;\n  line-height: 1.7;\n  color: #333;\n}\n\nh1 {\n  font-size: 2.5rem;\n  font-weight: 700;\n  text-align: center;\n  text-transform: uppercase;\n  letter-spacing: 2px;\n}\n\na {\n  text-decoration: none;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>font-family<\/code> lists fonts in order of preference. If the first is not available on the visitor&#8217;s device, the browser tries the next, and the last entry is a generic fallback like <code>sans-serif<\/code>.<\/li>\n\n\n\n<li><code>font-size: 16px;<\/code> sets the base text size for the page.<\/li>\n\n\n\n<li><code>line-height: 1.7;<\/code> sets the space between lines to 1.7 times the font size. A value between 1.5 and 1.8 usually reads well for body text.<\/li>\n\n\n\n<li><code>color: #333;<\/code> uses a dark gray, which is softer on the eyes than pure black.<\/li>\n\n\n\n<li><code>font-size: 2.5rem;<\/code> sizes the heading relative to the root font size, so it becomes 40px when the base is 16px.<\/li>\n\n\n\n<li><code>font-weight: 700;<\/code> makes the heading bold. Values run from 100 (thin) to 900 (heavy).<\/li>\n\n\n\n<li><code>text-align: center;<\/code> centers the heading horizontally.<\/li>\n\n\n\n<li><code>text-transform: uppercase;<\/code> displays the text in capital letters without changing the HTML.<\/li>\n\n\n\n<li><code>letter-spacing: 2px;<\/code> adds a little space between each character.<\/li>\n\n\n\n<li><code>text-decoration: none;<\/code> removes the default underline from links.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.<\/strong> <strong>px, em, and rem<\/strong><\/h3>\n\n\n\n<p>Pixels (<code>px<\/code>) are fixed. <code>em<\/code> is relative to the font size of the element&#8217;s parent, and <code>rem<\/code> is relative to the font size set on the root of the page.<\/p>\n\n\n\n<p>For font sizes, <code>rem<\/code> is a solid choice because it respects the size a user has chosen in their browser settings and keeps spacing consistent across the site.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Using a Web Font<\/strong><\/h3>\n\n\n\n<p>If you want a font that visitors may not have installed, you can load one from a service such as Google Fonts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;link href=\"https:\/\/fonts.googleapis.com\/css2?family=Poppins:wght@400;600&amp;display=swap\" rel=\"stylesheet\"&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>body {\n  font-family: \"Poppins\", sans-serif;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li>The <code>&lt;link&gt;<\/code> tag downloads the Poppins font in weights 400 (regular) and 600 (semi-bold).<\/li>\n\n\n\n<li><code>display=swap<\/code> shows fallback text right away and swaps in the web font once it loads.<\/li>\n\n\n\n<li>The CSS rule then applies it, with <code>sans-serif<\/code> as the backup.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The Box Model (Margin, Padding, Border)<\/strong><\/h2>\n\n\n\n<p>Every element on a web page is a rectangular box. The box model describes how the box is built, and it is behind most of the spacing problems beginners run into.<\/p>\n\n\n\n<p>A box is made of four layers, from the inside out:<\/p>\n\n\n\n<ul>\n<li><strong>Content:<\/strong> the text, image, or other material inside the element.<\/li>\n\n\n\n<li><strong>Padding:<\/strong> the space between the content and the border, inside the element.<\/li>\n\n\n\n<li><strong>Border:<\/strong> a line that wraps around the padding and content.<\/li>\n\n\n\n<li><strong>Margin:<\/strong> space outside the border that pushes other elements away.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>.card {\n  width: 300px;\n  padding: 20px;\n  border: 2px solid #333;\n  margin: 30px;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>width: 300px;<\/code> sets the width of the content area.<\/li>\n\n\n\n<li><code>padding: 20px;<\/code> adds 20px of space on all four sides inside the box.<\/li>\n\n\n\n<li><code>border: 2px solid #333;<\/code> draws a 2px solid dark gray line. A border needs a width, a style, and a color.<\/li>\n\n\n\n<li><code>margin: 30px;<\/code> leaves 30px of empty space around the outside of the box.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Setting Individual Sides<\/strong><\/h3>\n\n\n\n<p>You can set each side separately or use shorthand.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.card {\n  padding: 10px 20px;\n  margin: 10px 20px 30px 40px;\n  margin-bottom: 50px;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>padding: 10px 20px;<\/code> uses two values. The first is top and bottom, and the second is left and right.<\/li>\n\n\n\n<li><code>margin: 10px 20px 30px 40px;<\/code> uses four values, in the order top, right, bottom, left.<\/li>\n\n\n\n<li><code>margin-bottom: 50px;<\/code> overrides only the bottom margin from the line above it.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. The Width Problem and box-sizing<\/strong><\/h3>\n\n\n\n<p>By default, <code>width<\/code> only measures the content area. Padding and border are added on top. So the <code>.card<\/code> above ends up 344px wide in total: 300 for content, 40 for padding, and 4 for border.<\/p>\n\n\n\n<p>That can break layouts, so most developers change this behavior with <code>box-sizing<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>* {\n  box-sizing: border-box;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>*<\/code> targets every element on the page.<\/li>\n\n\n\n<li><code>border-box<\/code> makes <code>width<\/code> include the content, padding, and border together.<\/li>\n\n\n\n<li>With this rule, a 300px wide <code>.card<\/code> is exactly 300px wide on screen, no matter how much padding it has.<\/li>\n<\/ul>\n\n\n\n<p>Adding this rule at the top of almost every stylesheet is standard practice.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. A Note on Margins<\/strong><\/h3>\n\n\n\n<p>Vertical margins between two stacked elements can merge into one. If one paragraph has <code>margin-bottom: 30px<\/code> and the next has <code>margin-top: 20px<\/code>, the gap between them is 30px, not 50px. The larger value wins. This is called margin collapsing, and it applies only to vertical margins.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Display and Positioning<\/strong><\/h2>\n\n\n\n<p>Two properties control how elements are placed on a page: <code>display<\/code> decides how an element behaves in the flow of the page, and <code>position<\/code> decides whether it can be moved out of that flow.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. The Display Property<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>.block-item {\n  display: block;\n}\n\n.inline-item {\n  display: inline;\n}\n\n.inline-block-item {\n  display: inline-block;\n  width: 120px;\n  height: 60px;\n}\n\n.hidden-item {\n  display: none;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>block<\/code> elements start on a new line and stretch across the full width available. <code>&lt;div&gt;<\/code>, <code>&lt;p&gt;<\/code>, and headings are block by default.<\/li>\n\n\n\n<li><code>inline<\/code> elements sit within a line of text and take only as much width as their content needs. <code>&lt;span&gt;<\/code> and <code>&lt;a&gt;<\/code> are inline by default. Width and height settings have no effect on them.<\/li>\n\n\n\n<li><code>inline-block<\/code> sits in a line like an inline element, but accepts width, height, and vertical margins like a block element.<\/li>\n\n\n\n<li><code>none<\/code> removes the element from the page entirely, and it takes up no space.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. The Position Property<\/strong><\/h3>\n\n\n\n<p>The <code>position<\/code> property has five values. Offset properties like <code>top<\/code>, <code>right<\/code>, <code>bottom<\/code>, and <code>left<\/code> only work when the position is anything other than <code>static<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.parent {\n  position: relative;\n  height: 200px;\n  background-color: #e0e0e0;\n}\n\n.badge {\n  position: absolute;\n  top: 10px;\n  right: 10px;\n}\n\n.help-button {\n  position: fixed;\n  bottom: 20px;\n  right: 20px;\n}\n\n.section-title {\n  position: sticky;\n  top: 0;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>static<\/code> is the default. The element follows the normal flow, and offsets do nothing.<\/li>\n\n\n\n<li><code>relative<\/code> keeps the element in its normal place but lets you nudge it with offsets. It also makes the element a reference point for any absolutely positioned children.<\/li>\n\n\n\n<li><code>.badge<\/code> uses <code>absolute<\/code>, so it is removed from the normal flow and placed 10px from the top and right edges of <code>.parent<\/code>, its nearest positioned ancestor.<\/li>\n\n\n\n<li><code>.help-button<\/code> uses <code>fixed<\/code>, so it stays 20px from the bottom right corner of the browser window, even while the page scrolls.<\/li>\n\n\n\n<li><code>.section-title<\/code> uses <code>sticky<\/code>, so it scrolls normally until it reaches the top of the screen, then stays there until its container ends.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Controlling Overlap with z-index<\/strong><\/h3>\n\n\n\n<p>When positioned elements overlap, <code>z-index<\/code> decides which one appears on top.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.modal {\n  position: fixed;\n  z-index: 100;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li>A higher <code>z-index<\/code> sits above a lower one.<\/li>\n\n\n\n<li>It only works on elements that have a position value other than <code>static<\/code>.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Flexbox Basics<\/strong><\/h2>\n\n\n\n<p>Flexbox is a layout system for arranging items in a single row or a single column. It removes most of the older tricks people used for centering and spacing elements.<\/p>\n\n\n\n<p>To use it, you set <code>display: flex<\/code> on a parent element, called the flex container. Its direct children become flex items.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"menu\"&gt;\n  &lt;a href=\"#\"&gt;Home&lt;\/a&gt;\n  &lt;a href=\"#\"&gt;About&lt;\/a&gt;\n  &lt;a href=\"#\"&gt;Contact&lt;\/a&gt;\n&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>.menu {\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  gap: 16px;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>display: flex;<\/code> turns <code>.menu<\/code> into a flex container, and the three links line up in a row.<\/li>\n\n\n\n<li><code>justify-content: space-between;<\/code> spreads the items along the main axis, with the first at the start and the last at the end.<\/li>\n\n\n\n<li><code>align-items: center;<\/code> centers the items on the cross axis, which is vertical when the direction is a row.<\/li>\n\n\n\n<li><code>gap: 16px;<\/code> adds 16px of space between each item without needing margins.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Main Axis and Cross Axis<\/strong><\/h3>\n\n\n\n<p>Flexbox works with two directions. The <strong>main axis<\/strong> is the direction items flow in, and the <strong>cross axis<\/strong> runs perpendicular to it. By default the main axis is horizontal.<\/p>\n\n\n\n<p><code>justify-content<\/code> controls alignment on the main axis, while <code>align-items<\/code> controls the cross axis.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Changing Direction and Wrapping<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>.sidebar {\n  display: flex;\n  flex-direction: column;\n}\n\n.gallery {\n  display: flex;\n  flex-wrap: wrap;\n}\n<\/code><\/pre>\n\n\n\n<ul>\n<li><code>flex-direction: column;<\/code> stacks items vertically, so the main axis becomes vertical.<\/li>\n\n\n\n<li><code>flex-wrap: wrap;<\/code> lets items move to a new line when there isn&#8217;t enough room, instead of shrinking to fit.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.<\/strong> <strong>Common justify-content Values<\/strong><\/h3>\n\n\n\n<ul>\n<li><code>flex-start<\/code> places items at the beginning.<\/li>\n\n\n\n<li><code>center<\/code> places items in the middle.<\/li>\n\n\n\n<li><code>flex-end<\/code> places items at the end.<\/li>\n\n\n\n<li><code>space-between<\/code> puts equal space between items, with none at the edges.<\/li>\n\n\n\n<li><code>space-around<\/code> puts equal space around each item.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Making Items Share Space<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>.column {\n  flex: 1;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>flex: 1;<\/code> tells an item to grow and take an equal share of the available space.<\/li>\n\n\n\n<li>If three columns all have<code> flex: 1<\/code>, they end up the same width.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Centering Something Perfectly<\/strong><\/h3>\n\n\n\n<p>One of the most common uses of flexbox is centering content both horizontally and vertically.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.center-box {\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  height: 100vh;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>justify-content: center;<\/code> centers items horizontally.<\/li>\n\n\n\n<li><code>align-items: center;<\/code> centers them vertically.<\/li>\n\n\n\n<li><code>height: 100vh;<\/code> makes the container as tall as the browser window, which gives the vertical centering room to work.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>CSS Grid Basics<\/strong><\/h2>\n\n\n\n<p>CSS Grid is a layout system for arranging items in rows and columns at the same time. Flexbox handles one direction at a time, while Grid handles both, making it better suited to full-page layouts and card sections.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"products\"&gt;\n  &lt;div&gt;Item 1&lt;\/div&gt;\n  &lt;div&gt;Item 2&lt;\/div&gt;\n  &lt;div&gt;Item 3&lt;\/div&gt;\n  &lt;div&gt;Item 4&lt;\/div&gt;\n  &lt;div&gt;Item 5&lt;\/div&gt;\n  &lt;div&gt;Item 6&lt;\/div&gt;\n&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>.products {\n  display: grid;\n  grid-template-columns: repeat(3, 1fr);\n  gap: 20px;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>display: grid;<\/code> turns <code>.products<\/code> into a grid container.<\/li>\n\n\n\n<li><code>grid-template-columns: repeat(3, 1fr);<\/code> creates three columns of equal width.<\/li>\n\n\n\n<li><code>1fr<\/code> stands for one fraction of the available space, so three <code>1fr<\/code> columns each take a third.<\/li>\n\n\n\n<li><code>gap: 20px;<\/code> puts 20px of space between rows and columns.<\/li>\n\n\n\n<li>The six items fill the grid automatically, producing two rows of three.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Mixing Column Sizes<\/strong><\/h3>\n\n\n\n<p>Columns do not have to be equal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.layout {\n  display: grid;\n  grid-template-columns: 250px 1fr;\n  gap: 24px;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li>The first column is fixed at 250px, which works well for a sidebar.<\/li>\n\n\n\n<li>The second column, <code>1fr<\/code>, takes all the remaining space.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Spanning Multiple Columns<\/strong><\/h3>\n\n\n\n<p>An item can stretch across more than one column or row.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.featured {\n  grid-column: span 2;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>grid-column: span 2;<\/code> makes the item take up two columns instead of one.<\/li>\n\n\n\n<li>The other items move around it to fill the grid.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. A Responsive Grid Without Media Queries<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>.cards {\n  display: grid;\n  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));\n  gap: 20px;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>minmax(220px, 1fr)<\/code> sets each column to be at least 220px wide and lets it grow to share leftover space.<\/li>\n\n\n\n<li><code>auto-fit<\/code> fits as many columns as the container allows.<\/li>\n\n\n\n<li>On a wide screen you may get four columns, on a tablet two, and on a phone one, all from this single line.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Flexbox or Grid?<\/strong><\/h3>\n\n\n\n<p>Use Flexbox when you are arranging items along one line, such as a navigation bar or a row of buttons. <\/p>\n\n\n\n<p>Use Grid when you need control over rows and columns together, such as a photo gallery or a page layout. The two also work well together, with Grid shaping the page and Flexbox aligning items inside each cell.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Responsive Design with Media Queries<\/strong><\/h2>\n\n\n\n<p>Responsive design means a page adjusts to the screen it is viewed on, whether that is a phone, a tablet, or a wide desktop monitor. It relies on three things: a viewport setting, flexible sizing, and media queries.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. The Viewport Meta Tag<\/strong><\/h3>\n\n\n\n<p>Before any CSS works properly on mobile, this tag needs to be in the <code>&lt;head&gt;<\/code> of your HTML.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;<\/code><\/pre>\n\n\n\n<ul>\n<li><code>width=device-width<\/code> tells the browser to match the page width to the screen width.<\/li>\n\n\n\n<li><code>initial-scale=1.0<\/code> sets the starting zoom level to normal.<\/li>\n\n\n\n<li>Without this tag, phones often show a shrunken desktop version of the page.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Writing a Media Query<\/strong><\/h3>\n\n\n\n<p>A media query applies a block of CSS only when a condition is true, most often based on screen width.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.container {\n  display: flex;\n  flex-direction: column;\n  padding: 16px;\n}\n\n@media (min-width: 768px) {\n  .container {\n    flex-direction: row;\n    padding: 32px;\n  }\n}<\/code><\/pre>\n\n\n\n<ul>\n<li>The first rule is the default, so it applies to every screen size. Here the items stack in a column.<\/li>\n\n\n\n<li><code>@media (min-width: 768px)<\/code> means the rules inside apply only when the screen is 768px wide or larger.<\/li>\n\n\n\n<li>Inside the query, the direction switches to <code>row<\/code> and the padding increases.<\/li>\n\n\n\n<li>On a phone you see a stacked layout, and on a tablet or desktop the items sit side by side.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Mobile-First vs Desktop-First<\/strong><\/h3>\n\n\n\n<p>The example above is mobile-first. You write styles for small screens first, then use <code>min-width<\/code> queries to add changes for larger ones. This approach usually leads to simpler CSS, because small screens tend to need fewer layout rules.<\/p>\n\n\n\n<p>A desktop-first approach does the opposite, using <code>max-width<\/code> to override styles for smaller screens.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@media (max-width: 600px) {\n  .sidebar {\n    display: none;\n  }\n}<\/code><\/pre>\n\n\n\n<ul>\n<li>This hides the sidebar on screens 600px wide or smaller.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Common Breakpoints<\/strong><\/h3>\n\n\n\n<p>There are no official breakpoints; the best ones are wherever your layout starts to look broken. These values are a common starting point:<\/p>\n\n\n\n<ul>\n<li><code>480px<\/code> for small phones<\/li>\n\n\n\n<li><code>768px<\/code> for tablets<\/li>\n\n\n\n<li><code>1024px<\/code> for small laptops<\/li>\n\n\n\n<li><code>1200px<\/code> for larger desktop screens<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Flexible Images and Units<\/strong><\/h3>\n\n\n\n<p>Media queries work best alongside sizing that already adapts on its own.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>img {\n  max-width: 100%;\n  height: auto;\n}\n\n.wrapper {\n  width: 90%;\n  max-width: 1100px;\n  margin: 0 auto;\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><code>max-width: 100%;<\/code> stops an image from growing wider than its container.<\/li>\n\n\n\n<li><code>height: auto;<\/code> keeps the image proportions correct as it scales.<\/li>\n\n\n\n<li><code>.wrapper<\/code> takes 90% of the screen width but never grows past 1100px.<\/li>\n\n\n\n<li><code>margin: 0 auto;<\/code> centers the wrapper horizontally by splitting the leftover space equally on each side.<\/li>\n<\/ul>\n\n\n\n<p>Testing matters as much as writing the code. Open your <a href=\"https:\/\/developer.chrome.com\/docs\/devtools\/overview\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">browser&#8217;s developer tools<\/a>, switch on the device toolbar, and resize the window to see where your layout needs adjusting.<\/p>\n\n\n\n<p><strong>Also Read:<\/strong> <em><a href=\"https:\/\/www.guvi.in\/blog\/guide-for-debugging-css\/\" target=\"_blank\" rel=\"noreferrer noopener\">Debugging CSS<\/a><\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>CSS Tutorial Quick Reference: Concepts and Learning Time<\/strong><\/h2>\n\n\n\n<p>This CSS Tutorial quick reference lists each core concept with the time it usually takes to learn, so you can plan your practice before you start:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><strong>Concept<\/strong><\/th><th><strong>What It Covers<\/strong><\/th><th><strong>Difficulty Level<\/strong><\/th><th><strong>Time to Learn<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Selectors<\/strong><\/td><td>Targeting elements by tag, class, and ID<\/td><td>Easy<\/td><td>20 minutes<\/td><\/tr><tr><td><strong>Properties and Values<\/strong><\/td><td>Setting how an element looks, such as color or font-size<\/td><td>Easy<\/td><td>15 minutes<\/td><\/tr><tr><td><strong>Specificity<\/strong><\/td><td>Deciding which rule wins when styles conflict<\/td><td>Medium<\/td><td>30 minutes<\/td><\/tr><tr><td><strong>Color Formats<\/strong><\/td><td>Names, HEX, RGB, and HSL values<\/td><td>Easy<\/td><td>20 minutes<\/td><\/tr><tr><td><strong>Margin and Padding<\/strong><\/td><td>Space outside and inside an element<\/td><td>Easy<\/td><td>25 minutes<\/td><\/tr><tr><td><strong>Display Property<\/strong><\/td><td>Block, inline, inline-block, and none<\/td><td>Easy<\/td><td>20 minutes<\/td><\/tr><tr><td><strong>Position Property<\/strong><\/td><td>Static, relative, absolute, fixed, and sticky<\/td><td>Medium<\/td><td>45 minutes<\/td><\/tr><tr><td><strong>Flexbox<\/strong><\/td><td>Aligning and spacing items in a row or column<\/td><td>Medium<\/td><td>1 hour<\/td><\/tr><tr><td><strong>CSS Grid<\/strong><\/td><td>Placing items into rows and columns<\/td><td>Medium<\/td><td>1 hour<\/td><\/tr><tr><td><strong>Media Queries<\/strong><\/td><td>Applying styles at different screen widths<\/td><td>Medium<\/td><td>40 minutes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQs<\/strong><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1790604569488\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">1. What is CSS used for?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>CSS controls how a web page looks. It sets colors, fonts, spacing, and layout, while HTML provides the structure and content.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1790604571140\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">2. What are the three ways to add CSS to HTML?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Inline CSS goes inside a tag with the <code>style<\/code> attribute, internal CSS goes inside a <code>&lt;style><\/code> tag in the <code>&lt;head><\/code>, and external CSS lives in a separate <code>.css<\/code> file linked with a <code>&lt;link><\/code> tag. External CSS is the best choice for most websites.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1790604572239\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">3. How long does it take to learn CSS basics?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>The core concepts in this CSS Tutorial add up to roughly 7 hours of focused practice. Getting comfortable with layouts and building pages on your own usually takes a few weeks of regular practice.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1790604574639\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">4. What is the difference between Flexbox and CSS Grid?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Flexbox arranges items in one direction, either a row or a column. Grid works with rows and columns together, so it suits full-page layouts and card sections better.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1790604578371\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">5. What is the box model in CSS?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>The box model describes every element as a box made of four layers: content, padding, border, and margin. It determines an element&#8217;s total size and the space around it.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Every website you admire, from a clean portfolio to a busy online store, gets its look from CSS. It decides the colors, the spacing, the fonts, and how a page rearranges itself on your phone. This guide skips the long theory and covers the parts of CSS you will use most often. Go through the [&hellip;]<\/p>\n","protected":false},"author":64,"featured_media":141489,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[294],"tags":[],"views":"10492","authorinfo":{"name":"Abhishek Pati","url":"https:\/\/www.guvi.in\/blog\/author\/abhishek-pati\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2024\/02\/Complete-CSS-Tutorial-300x116.webp","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/42673"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=42673"}],"version-history":[{"count":38,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/42673\/revisions"}],"predecessor-version":[{"id":141499,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/42673\/revisions\/141499"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/141489"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=42673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=42673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=42673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}