<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saravanan Lakshmanan</title>
    <description>The latest articles on DEV Community by Saravanan Lakshmanan (@dev_saravanan_journey).</description>
    <link>https://dev.to/dev_saravanan_journey</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3927221%2F86db017d-8633-4bd5-9ac1-97ee29f0d80e.png</url>
      <title>DEV Community: Saravanan Lakshmanan</title>
      <link>https://dev.to/dev_saravanan_journey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dev_saravanan_journey"/>
    <language>en</language>
    <item>
      <title>Immutable vs Mutable ||JavaScript Type Conversion</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Tue, 02 Jun 2026 10:29:16 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/immutable-vs-mutable-javascript-type-conversion-3c03</link>
      <guid>https://dev.to/dev_saravanan_journey/immutable-vs-mutable-javascript-type-conversion-3c03</guid>
      <description>&lt;p&gt;&lt;strong&gt;Immutable vs Mutable (Non-Immutable)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Immutable&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An immutable value cannot be changed after it is created.&lt;/li&gt;
&lt;li&gt;When you modify it, JavaScript creates a new value instead of changing the original one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;let a = "Hello";&lt;br&gt;
a = "Hi";&lt;/code&gt;&lt;br&gt;
What happens?&lt;br&gt;
&lt;code&gt;"Hello"   // old value remains unchanged&lt;br&gt;
"Hi"      // new value is created&lt;/code&gt;&lt;br&gt;
The variable a now points to the new value "Hi".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Immutable Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;Number&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Null&lt;/li&gt;
&lt;li&gt;Undefined&lt;/li&gt;
&lt;li&gt;Symbol&lt;/li&gt;
&lt;li&gt;BigInt&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Mutable (Non-Immutable)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A mutable value can be changed after it is created.&lt;/li&gt;
&lt;li&gt;Instead of creating a new value, JavaScript modifies the existing object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
`let user = {&lt;br&gt;
  name: "John"&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;user.name = "David";&lt;code&gt;&lt;br&gt;
What happens?&lt;br&gt;
&lt;/code&gt;{&lt;br&gt;
  name: "David"&lt;br&gt;
}`&lt;br&gt;
The same object is updated. No new object is required for this change.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mutable Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Object&lt;/li&gt;
&lt;li&gt;Array&lt;/li&gt;
&lt;li&gt;Function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Quick Comparison&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Immutable&lt;/th&gt;
&lt;th&gt;Mutable&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cannot be changed directly&lt;/td&gt;
&lt;td&gt;Can be changed directly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modification creates a new value&lt;/td&gt;
&lt;td&gt;Modification updates the existing value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Primitive data types&lt;/td&gt;
&lt;td&gt;Non-primitive data types&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Example: String, Number&lt;/td&gt;
&lt;td&gt;Example: Object, Array&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Easy Memory Trick&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Immutable&lt;/strong&gt; = New value is created when changed&lt;br&gt;
&lt;code&gt;let x = 10;&lt;br&gt;
x = 20;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mutable&lt;/strong&gt; = Existing value is updated&lt;br&gt;
&lt;code&gt;let arr = [1, 2];&lt;br&gt;
arr.push(3);&lt;/code&gt;&lt;br&gt;
x = 20 creates a new value, while arr.push(3) changes the existing array.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;JavaScript Type Conversion&lt;/strong&gt;&lt;br&gt;
In JavaScript Type Conversion can be defined as converting the data type of the variables from one type to the other manually by the programmer(explicitly) or automatically by the JavaScript(implicitly).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Implicit Type Conversion (Coercion):&lt;/strong&gt; Implicit Type Conversion occurs automatically by the JavaScript.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Explicit Type Conversion:&lt;/strong&gt; Explicit Type Conversion occurs when the programmer manually changes the type of the variables using the function Number(), String(), and Boolean().&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Implicit Type Conversion (Coercion)&lt;/strong&gt;&lt;br&gt;
In JavaScript, the implicit type conversion or coercion conversion can be defined as the automatic conversion of the data type of the variables from one type to another type. Implicit type conversion mostly occurs when we are performing the arithmetic or the logical operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;String with Number (Concatenation)&lt;/strong&gt;&lt;br&gt;
When we add a string with the number, the JavaScript automatically converts the number into a string and performs string concatenation.&lt;br&gt;
&lt;code&gt;let res = 5 + "5";  &lt;br&gt;
console.log(res);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boolean to Number&lt;/strong&gt;&lt;br&gt;
When we perform the mathematical operations, then JavaScript automatically converts true to 1 and false to 0.&lt;br&gt;
&lt;code&gt;let res = true + 1;  &lt;br&gt;
console.log(res);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Equality Comparison (==)&lt;/strong&gt;&lt;br&gt;
When we use the equality operator in the JavaScript, it compares them after converting the value into the same data type.&lt;br&gt;
&lt;code&gt;let res = (5 == "5");  &lt;br&gt;
console.log(res);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automatic Conversion in Logical Operations&lt;/strong&gt;&lt;br&gt;
In JavaScript, these values are automatically converts undefined, null, "" (empty string), false, NaN, and 0 to false, and all other values to true.&lt;br&gt;
&lt;code&gt;let res = Boolean("");  &lt;br&gt;
let res2 = Boolean("Hello");  &lt;br&gt;
console.log(res)&lt;br&gt;
console.log(res2)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explicit Type Conversion&lt;/strong&gt;&lt;br&gt;
In JavaScript, explicit type conversion can be defined as when we manually change the data type of the variable from one to other using some built-in JavaScript functions. JavaScript provides us the built-in functions for performing the explicit conversion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Converting to String&lt;/strong&gt;&lt;br&gt;
In JavaScript, we can convert the value into a string using the String() function, toString(), and by concatenating the empty string.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let n = 123;&lt;br&gt;
let s1 = String(n);  &lt;br&gt;
let s2 = n.toString();  &lt;br&gt;
console.log(s1)&lt;br&gt;
console.log(s2)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Converting to Number&lt;/strong&gt;&lt;br&gt;
In JavaScript, we can convert the value into a number using the Number() function, parseInt(), and parseFloat().&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let s = "123";&lt;br&gt;
let n = Number(s);  &lt;br&gt;
let s1 = "12.34";&lt;br&gt;
let n1 = parseFloat(s1);  &lt;br&gt;
console.log(n)&lt;br&gt;
console.log(n1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Converting to Boolean&lt;/strong&gt;&lt;br&gt;
In JavaScript, we can convert the value into a boolean we can use the Boolean() function.&lt;br&gt;
&lt;code&gt;let str = "Hello";&lt;br&gt;
let b1 = Boolean(str);  &lt;br&gt;
let emptyStr = "";&lt;br&gt;
let b2 = Boolean(emptyStr);  &lt;br&gt;
console.log(b1)&lt;br&gt;
console.log(b2)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reasons to Learn JavaScript Type Conversion&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data Handling: In JavaScript when we are working with API responses, user inputs and calculations, these type of the operation require type conversion.&lt;/li&gt;
&lt;li&gt;Prevent Bugs: It is important to understand the type conversion which can help in preventing bugs which occurs when JavaScript implicitly converts value.&lt;/li&gt;
&lt;li&gt;Code Clarity: By performing the explicit conversion makes our code bug free and more clear.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;JavaScript Type Conversion&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Conversion Type&lt;/th&gt;
&lt;th&gt;Implicit Conversion (Coercion)&lt;/th&gt;
&lt;th&gt;Explicit Conversion&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;String + Number&lt;/td&gt;
&lt;td&gt;Automatically converts numbers to strings&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;String()&lt;/code&gt; or &lt;code&gt;.toString()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Number + Boolean&lt;/td&gt;
&lt;td&gt;Converts &lt;code&gt;true&lt;/code&gt; to &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;Number()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;String to Boolean&lt;/td&gt;
&lt;td&gt;Non-empty strings become &lt;code&gt;true&lt;/code&gt;, empty strings become &lt;code&gt;false&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;Boolean()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Number from String&lt;/td&gt;
&lt;td&gt;JavaScript may convert automatically during operations&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;Number()&lt;/code&gt;, &lt;code&gt;parseInt()&lt;/code&gt;, or &lt;code&gt;parseFloat()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/javascript/javascript-type-conversion/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/javascript/javascript-type-conversion/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/js/js_type_conversion.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/js_type_conversion.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://immutable-js.com/" rel="noopener noreferrer"&gt;https://immutable-js.com/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/javascript/why-is-immutability-so-important-in-javascript/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/javascript/why-is-immutability-so-important-in-javascript/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typecast</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Introduction to JavaScript</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Mon, 01 Jun 2026 10:17:09 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/introduction-to-javascript-3bbm</link>
      <guid>https://dev.to/dev_saravanan_journey/introduction-to-javascript-3bbm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction to JavaScript&lt;/strong&gt;&lt;br&gt;
JavaScript is a versatile, dynamically typed programming language that brings life to web pages by making them interactive. It is used for building interactive web applications and supports both client-side and server-side development.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interpreted language: Code is executed line by line.&lt;/li&gt;
&lt;li&gt;Dynamically typed: Variable types are determined at runtime.&lt;/li&gt;
&lt;li&gt;Single-threaded: Executes one task at a time (but supports asynchronous operations).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Features of JavaScript&lt;/strong&gt;&lt;br&gt;
Here are some key features of JavaScript that make it a powerful language for web development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client-Side Scripting: JavaScript runs on the user's browser, so it has a faster response time without needing to communicate with the server.&lt;/li&gt;
&lt;li&gt;Versatile: Can be used for a wide range of tasks, from simple calculations to complex server-side applications.&lt;/li&gt;
&lt;li&gt;Event-Driven: Responds to user actions (clicks, keystrokes) in real-time.&lt;/li&gt;
&lt;li&gt;Asynchronous: It can handle tasks like fetching data from servers without freezing the user interface.&lt;/li&gt;
&lt;li&gt;Rich Ecosystem: There are numerous libraries and frameworks built on JavaScript, such as React, Angular, and Vue.js, which make development faster and more efficient.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Client Side and Server Side nature of JavaScript&lt;/strong&gt;&lt;br&gt;
JavaScript's flexibility extends to both the client-side and server-side, allowing developers to create complete web applications. Here’s how it functions in each environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client-Side: Involves controlling the browser and its DOM (Document Object Model). Handles user events like clicks and form inputs. Common libraries include AngularJS, ReactJS, and VueJS.&lt;/li&gt;
&lt;li&gt;Server-Side: Involves interacting with databases, manipulating files, and generating responses. Node.js and frameworks like Express.js are widely used for server-side JavaScript, enabling full-stack development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What Can JavaScript Do?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript is the programming language of the web.&lt;/li&gt;
&lt;li&gt;It can calculate, manipulate and validate data.&lt;/li&gt;
&lt;li&gt;It can update and change both HTML and CSS.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;JavaScript Can Change HTML Content&lt;/strong&gt;&lt;br&gt;
One of many JavaScript HTML methods is getElementById().&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a JavaScript Compiler?&lt;/strong&gt;&lt;br&gt;
A compiler is a program that translates code written in one programming language into another language or a lower-level representation. In the context of JavaScript, a compiler translates human-readable JavaScript code into machine code or bytecode that can be executed by the computer’s CPU.&lt;br&gt;
Unlike traditional compiled languages like C++ or Java, JavaScript is typically executed by an interpreter in the browser. However, modern JavaScript engines (like V8, SpiderMonkey, and JavaScriptCore) use a combination of interpretation and compilation to optimize performance. This approach is known as Just-In-Time (JIT) compilation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript Data Types&lt;/strong&gt;&lt;br&gt;
A JavaScript variable can hold 8 types of data.&lt;/p&gt;

&lt;p&gt;7 Primitive Data Types and 1 Object Data Type.&lt;/p&gt;

&lt;p&gt;JavaScript data types are broadly classified into two categories:&lt;br&gt;
&lt;code&gt;JavaScript Data Types&lt;br&gt;
│&lt;br&gt;
├── Primitive Data Types&lt;br&gt;
│   ├── String&lt;br&gt;
│   ├── Number&lt;br&gt;
│   ├── Boolean&lt;br&gt;
│   ├── Undefined&lt;br&gt;
│   ├── Null&lt;br&gt;
│   ├── BigInt&lt;br&gt;
│   └── Symbol&lt;br&gt;
│&lt;br&gt;
└── Non-Primitive (Reference) Data Types&lt;br&gt;
    ├── Object&lt;br&gt;
    ├── Array&lt;br&gt;
    └── Function&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Point:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Primitive data types store a single value.&lt;/li&gt;
&lt;li&gt;Non-primitive data types store collections of data and are accessed through references.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;JavaScript Variables&lt;/strong&gt;&lt;br&gt;
Variables = Data Containers&lt;br&gt;
JavaScript variables are containers for data.&lt;/p&gt;

&lt;p&gt;JavaScript variables can be declared in 4 ways:&lt;br&gt;
&lt;strong&gt;Modern JavaScript&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using let&lt;/li&gt;
&lt;li&gt;Using const&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Older JavaScript&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using var (Not Recommended)&lt;/li&gt;
&lt;li&gt;Automatically (Not Recommended)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Variables in JavaScript are used to store data values. They can be declared in different ways depending on how the value should behave.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables can be declared using var, let, or const.&lt;/li&gt;
&lt;li&gt;JavaScript is dynamically typed, so types are decided at runtime.&lt;/li&gt;
&lt;li&gt;You don’t need to specify a data type when creating a variable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Declaring Variables in JavaScript&lt;/strong&gt;&lt;br&gt;
Before ES6 (2015): Variables were declared only with var, which is function-scoped and global-scoped, causing issues like hoisting and global pollution.&lt;br&gt;
ES6 Introduction:let and const were introduced to provide safer alternatives for declaring variables.&lt;br&gt;
Scope: let and const are block-scoped (limited to { } block) or global-scoped, reducing errors compared to var.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. var keyword&lt;/strong&gt;&lt;br&gt;
var is a keyword in JavaScript used to declare variables and it is Function-scoped and hoisted, allowing redeclaration but can lead to unexpected bugs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var a = "Hello Geeks";&lt;br&gt;
var b = 10;&lt;br&gt;
console.log(a);&lt;br&gt;
console.log(b);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. let keyword&lt;/strong&gt;&lt;br&gt;
let is a keyword in JavaScript used to declare variables and it is Block-scoped and not hoisted to the top, suitable for mutable variables&lt;br&gt;
&lt;code&gt;let a = 12&lt;br&gt;
let b = "gfg";&lt;br&gt;
console.log(a);&lt;br&gt;
console.log(b);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. const keyword&lt;/strong&gt;&lt;br&gt;
const is a keyword in JavaScript used to declare variables and it is Block-scoped, immutable bindings that can't be reassigned, though objects can still be mutated.&lt;br&gt;
&lt;code&gt;const a = 5&lt;br&gt;
let b = "gfg";&lt;br&gt;
console.log(a);&lt;br&gt;
console.log(b);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules for Naming Variables&lt;/strong&gt;&lt;br&gt;
When naming variables in JavaScript, follow these rules&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variable names must begin with a letter, underscore (_), or dollar sign ($).&lt;/li&gt;
&lt;li&gt;Subsequent characters can be letters, numbers, underscores, or dollar signs.&lt;/li&gt;
&lt;li&gt;Variable names are case-sensitive (e.g., age and Age are different variables).&lt;/li&gt;
&lt;li&gt;Reserved keywords (like function, class, return, etc.) cannot be used as variable names.
&lt;code&gt;let userName = "Suman";  // Valid
let $price = 100;         // Valid
let _temp = 0;            // Valid
let 123name = "Ajay";    // Invalid
let function = "gfg"; // Invalid&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Radio Button Vs Checkbox in HTML</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Thu, 28 May 2026 16:10:03 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/radio-button-vs-checkbox-in-html-34g8</link>
      <guid>https://dev.to/dev_saravanan_journey/radio-button-vs-checkbox-in-html-34g8</guid>
      <description>&lt;p&gt;&lt;strong&gt;Radio Button Vs Checkbox in HTML&lt;/strong&gt;&lt;br&gt;
Radio buttons allow users to select only one option from a group, while checkboxes permit multiple selections. Use radio buttons when exclusive choices are needed, and checkboxes for multiple independent choices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;These are the following topics that we are going to discuss:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table of Content&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Radio button&lt;/li&gt;
&lt;li&gt;Checkbox&lt;/li&gt;
&lt;li&gt;Difference between radio button and checkbox&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Radio button&lt;/strong&gt;&lt;br&gt;
It is generally used in HTML forms. HTML forms are required when you need to collect some data from site visitors. A radio button is used when you want to select only one option out of several available options.&lt;br&gt;
Example: This example shows the use of Radio buttons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;GeeksfoGeeks&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
        Do you agree this statement?
        &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"radio"&lt;/span&gt; 
               &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"agree"&lt;/span&gt; 
               &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"yes"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Yes
        &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"radio"&lt;/span&gt; 
               &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"agree"&lt;/span&gt; 
               &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"no"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;No
        &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Checkbox&lt;/strong&gt;&lt;br&gt;
Checkboxes are also mostly used in HTML forms. A checkbox allows you to choose one or many options to be selected from a list of options.&lt;/p&gt;

&lt;p&gt;Example: This example shows the use of checkbox.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;HTML Checkboxes&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
        Choose languages you know:
        &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; 
               &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"C"&lt;/span&gt; 
               &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"yes"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;C
        &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; 
               &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"C++"&lt;/span&gt; 
               &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"yes"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;C++
        &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; 
               &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Java"&lt;/span&gt; 
               &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"yes"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Java
        &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; 
               &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Python"&lt;/span&gt; 
               &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"yes"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Python
        &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Difference Between Radio Button and Checkbox in HTML
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Radio Button
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Used when only &lt;strong&gt;one option&lt;/strong&gt; should be selected from multiple available choices.&lt;/li&gt;
&lt;li&gt;Created using the HTML &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; tag with &lt;code&gt;type="radio"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Works as a &lt;strong&gt;single selection control&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Displayed as a &lt;strong&gt;small circle&lt;/strong&gt; on the screen.&lt;/li&gt;
&lt;li&gt;Has 2 states: &lt;strong&gt;Selected&lt;/strong&gt; and &lt;strong&gt;Unselected&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Mainly used when you want to &lt;strong&gt;restrict the user to one choice only&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"radio"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"gender"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; Male
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"radio"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"gender"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; Female
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Checkbox
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Used when &lt;strong&gt;one or multiple options&lt;/strong&gt; can be selected.&lt;/li&gt;
&lt;li&gt;Created using the HTML &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; tag with &lt;code&gt;type="checkbox"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Works as a &lt;strong&gt;multiple selection control&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Displayed as a &lt;strong&gt;small square box&lt;/strong&gt; on the screen.&lt;/li&gt;
&lt;li&gt;Has 3 states: &lt;strong&gt;Checked, Unchecked, and Indeterminate&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Mainly used when you want to &lt;strong&gt;allow users to select multiple choices&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; HTML
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; CSS
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; JavaScript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;Radio Buttons&lt;/strong&gt; for single selection.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;Checkboxes&lt;/strong&gt; for multiple selections.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/html/radio-button-vs-checkbox-in-html/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/html/radio-button-vs-checkbox-in-html/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://byjus.com/gate/difference-between-radio-button-and-checkbox/" rel="noopener noreferrer"&gt;https://byjus.com/gate/difference-between-radio-button-and-checkbox/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.nngroup.com/articles/checkboxes-vs-radio-buttons/" rel="noopener noreferrer"&gt;https://www.nngroup.com/articles/checkboxes-vs-radio-buttons/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>CSS Media Queries, CSS Outline, CSS Units</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Wed, 27 May 2026 10:49:35 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/css-media-queries-css-outline-css-units-4hdn</link>
      <guid>https://dev.to/dev_saravanan_journey/css-media-queries-css-outline-css-units-4hdn</guid>
      <description>&lt;p&gt;&lt;strong&gt;CSS Media Queries&lt;/strong&gt;&lt;br&gt;
CSS Media Queries enable web pages to adjust their layout and styles based on different screen sizes, devices, or orientations. They are essential for building responsive and adaptable web designs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Apply CSS rules conditionally based on screen width or height.&lt;/li&gt;
&lt;li&gt;Help create responsive layouts for mobile, tablet, and desktop devices.&lt;/li&gt;
&lt;li&gt;Support conditions like orientation, resolution, and device type.&lt;/li&gt;
&lt;li&gt;Improve user experience across different devices.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        .gfg {
            color: black;
        }
        @media screen and (max-width: 500px) {
            .gfg {
                color: green;
            }
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="gfg"&amp;gt;Sample Example of Media Query&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Media queries apply CSS rules based on device characteristics like screen width.&lt;/li&gt;
&lt;li&gt;In your code, screens ≤500px wide change .gfg text color to green.
Syntax:
&lt;code&gt;@media mediatype and (condition) {  /* CSS styles */}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Media Types in CSS&lt;/strong&gt;&lt;br&gt;
Media types specify which devices the styles should apply to. Commonly used types include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;all → Suitable for all media devices.&lt;/li&gt;
&lt;li&gt;print → Used for printers.&lt;/li&gt;
&lt;li&gt;screen → Targeted at computer screens, tablets, smartphones, etc.&lt;/li&gt;
&lt;li&gt;speech → Designed for screen readers that read the content aloud.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Media Queries for Multiple Screen Sizes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;style&amp;gt;
        .gfg {
            color: black;
        }
        @media screen and (max-width: 800px) {
            .gfg {
                color: blue;
            }
        }
        @media screen and (max-width: 500px) {
            .gfg {
                color: green;
            }
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="gfg"&amp;gt;Sample Example of Media Query&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Styles adjust dynamically based on screen width using media queries.&lt;/li&gt;
&lt;li&gt;For screens 800px or smaller, the text color changes to blue.&lt;/li&gt;
&lt;li&gt;For screens 500px or smaller, the text color changes to green.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Media Queries for Multiple Screen Sizes with Additional Styles&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;style&amp;gt;
        .gfg {
            color: black;
            font-size: 20px;
            padding: 10px;
        }
        @media screen and (max-width: 800px) {
            .gfg {
                color: blue;
                font-size: 18px;
            }
        }
        @media screen and (max-width: 500px) {
            .gfg {
                color: green;
                font-size: 16px;
                text-align: center;
            }
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="gfg"&amp;gt;Sample Example of Media Query&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Styles dynamically adjust based on screen width using media queries.&lt;/li&gt;
&lt;li&gt;For screens 800px or smaller, the text color becomes blue, and the font size decreases to 18px.&lt;/li&gt;
&lt;li&gt;For screens 500px or smaller, the text color changes to green, the font size reduces to 16px, and the text is center-aligned.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CSS Media Query Features&lt;/strong&gt;&lt;br&gt;
Media queries allow developers to check various device characteristics. Here are some important features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;color → Specifies the number of bits per color component for the device.&lt;/li&gt;
&lt;li&gt;grid → Checks whether the device is grid or bitmap.&lt;/li&gt;
&lt;li&gt;height → Represents the height of the viewport.&lt;/li&gt;
&lt;li&gt;aspect-ratio → Defines the width-to-height ratio of the viewport.&lt;/li&gt;
&lt;li&gt;color-index → Indicates how many colors the device can display.&lt;/li&gt;
&lt;li&gt;max-resolution → The highest resolution the device can achieve, measured in dpi or dpcm.&lt;/li&gt;
&lt;li&gt;monochrome → Shows the number of bits per color on a monochrome device.&lt;/li&gt;
&lt;li&gt;scan → Refers to the method of scanning used by the output device.&lt;/li&gt;
&lt;li&gt;update → Describes how fast the device can update its display.&lt;/li&gt;
&lt;li&gt;width → Represents the width of the viewport.&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;&lt;strong&gt;CSS Outline&lt;/strong&gt;&lt;br&gt;
CSS outline is a property used to draw a line around an element's border. It does not affect the layout, unlike borders. It's often used to highlight elements, providing a visual emphasis without altering the dimensions of the element.&lt;br&gt;
&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;selector{&lt;br&gt;
    outline: outline-width outline-type outline-color;&lt;br&gt;
    /*outline: 2px solid grey;*/&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example: This example uses the outline property to create a dashed blue outline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        .dotted {
            outline: 2px dashed blue;
            color: green;
            text-align: center;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;GeeksforGeeks&amp;lt;/h1&amp;gt;
    &amp;lt;h3&amp;gt;Outline Property&amp;lt;/h3&amp;gt;
    &amp;lt;p class="dotted"&amp;gt;
        A Computer Science portal for geeks.
    &amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS outline properties can be categorized into 4 types, namely, Outline-style, Outline-color, Outline-width &amp;amp; Outline-offset. We will discuss all the types of outline properties sequentially through the examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CSS Outline Properties&lt;/strong&gt;&lt;br&gt;
There are lots of properties comes under the CSS outline collection all of them are well described with the example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table of Content&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Outline-style&lt;/li&gt;
&lt;li&gt;Outline-color&lt;/li&gt;
&lt;li&gt;Outline-width&lt;/li&gt;
&lt;li&gt;Outline-offset&lt;/li&gt;
&lt;/ol&gt;



&lt;p&gt;&lt;strong&gt;Difference between em and rem units in CSS&lt;/strong&gt;&lt;br&gt;
The em is based on the parent font size so that it can change in nested elements, while rem is based on the root font size, keeping the size same throughout the whole page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. em Unit&lt;/strong&gt;&lt;br&gt;
The em unit in CSS is relative to the font size of its parent element. It scales based on the current element’s font size, affecting the size of nested elements according to their parent's size.&lt;/p&gt;

&lt;p&gt;When em is used for font-size, it’s based on the parent’s font size. For other properties, it’s based on the element’s font size, except in the first declaration where the parent is referenced.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt; 
    &amp;lt;style&amp;gt;
        .parent {
            font-size: 20px;
        }

        .child-em {
            font-size: 2em;
            margin: 1.5em;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;div class="parent"&amp;gt;
        This is parent
        &amp;lt;div class="child-em"&amp;gt;
            This is Child in em unit system
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. rem Unit&lt;/strong&gt;&lt;br&gt;
The rem unit in CSS is relative to the font size of the root element (). It provides consistent scaling across the entire document, ensuring that elements are sized relative to a single base font size.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        .parent {
            font-size: 20px;
        }

        .child-rem {
            font-size: 2rem;
            margin: 1.5rem;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;div class="parent"&amp;gt;
        This is parent
        &amp;lt;div class="child-rem"&amp;gt;
            This is Child in rem unit system
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://www.w3schools.com/css/css3_mediaqueries.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/css/css3_mediaqueries.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Media_queries/Using" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Media_queries/Using&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Media_queries/Using" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Media_queries/Using&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/css/css-media-queries/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/css/css-media-queries/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/css/css-outline/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/css/css-outline/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>CSS Selectors</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Tue, 26 May 2026 13:46:10 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/css-selectors-3jf1</link>
      <guid>https://dev.to/dev_saravanan_journey/css-selectors-3jf1</guid>
      <description>&lt;p&gt;&lt;strong&gt;CSS Selectors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;CSS Selectors are patterns used in CSS to select and target HTML elements so that styles can be applied to them. They define which elements on a web page should receive specific styling rules.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used to select HTML elements based on tag name, class, id, or attributes.&lt;/li&gt;
&lt;li&gt;Help apply styles like color, font, spacing, and layout.&lt;/li&gt;
&lt;li&gt;Make web pages structured, consistent, and visually appealing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CSS selectors are commonly grouped into five main categories:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Basic Selectors&lt;/strong&gt;&lt;br&gt;
Basic selectors in CSS are simple tools used for selecting by HTML element name (e.g., h1), class (.class Name), ID (#idName), or universally (* for all elements).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Universal Selector (*):&lt;/strong&gt; Selects all elements on the page and applies the same style universally.&lt;/p&gt;

&lt;p&gt;Example: Setting the font color for every element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        * {
            color: red;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Header Text&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;Paragraph Text&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Element Selector:&lt;/strong&gt; Targets all elements of a specific type, such as paragraphs or headers.&lt;/p&gt;

&lt;p&gt;Example: Setting a common font size for all paragraphs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        p {
            font-size: 16px;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;p&amp;gt;This paragraph styled with font size 16px.&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Class Selector (.):&lt;/strong&gt; Applies styles to elements with a specific class attribute.&lt;/p&gt;

&lt;p&gt;Example: Making all buttons have a blue background.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        .button {
            background-color: blue;
            color: white;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;button class="button"&amp;gt;Click Me!&amp;lt;/button&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. ID Selector (#):&lt;/strong&gt; Styles a single element identified by its unique id.&lt;/p&gt;

&lt;p&gt;Example: changing the background color of a header.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        #header {
            background-color: gray;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div id="header"&amp;gt;This is the header section.&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Combinator Selectors&lt;/strong&gt;&lt;br&gt;
Used to define relationships between selectors, allowing you to style elements based on their hierarchy or positioning in the document. Common combinators include descendant ( ), child (&amp;gt;), adjacent sibling (+), and general sibling (~).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Descendant Selectors:&lt;/strong&gt; Targets an element inside another, such as paragraphs inside div .&lt;/p&gt;

&lt;p&gt;Example: Styling paragraphs inside a div.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        div p {
            color: red;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;This paragraph inside a div will be red.&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Child Selector (&amp;gt;):&lt;/strong&gt; They only affects the direct child elements of a parent.&lt;/p&gt;

&lt;p&gt;Example: Styling direct children paragraphs of a div.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        div&amp;gt;p {
            margin-left: 20px;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;This is a direct child and has a left margin.&amp;lt;/p&amp;gt;
        &amp;lt;div&amp;gt;
            &amp;lt;p&amp;gt;This is not a direct child.&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Adjacent Sibling Selector (+):&lt;/strong&gt; Styles an element immediately following another .&lt;/p&gt;

&lt;p&gt;Example: Making the first paragraph bold after an h1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        h1+p {
            font-weight: bold;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;This is a header.&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;This is immediately following the header and is bold.&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;This will not be bold.&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. General Sibling Selector (~):&lt;/strong&gt; Styles all siblings that follow a specific element.&lt;/p&gt;

&lt;p&gt;Example: Italicizing all paragraphs following an h1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        h1~p {
            font-style: italic;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;This is a header.&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;This is a sibling of the header and will be italicized.&amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;This will also be italicized because it's a sibling of the header.&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Attribute Selectors&lt;/strong&gt;&lt;br&gt;
Attribute selectors in CSS target elements based on the presence or value of their attributes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Presence Selector:&lt;/strong&gt; It selects elements that contain a specific attribute.&lt;/p&gt;

&lt;p&gt;Example: styling all inputs with a type attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        input[type] {
            border: 2px solid black;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;input type="text" placeholder="Text input"&amp;gt;
    &amp;lt;input type="number" placeholder="Number input"&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Attribute Value Selector:&lt;/strong&gt; It targets elements with a particular attribute value.&lt;/p&gt;

&lt;p&gt;Example: Styling text inputs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        input[type="text"] {
            background-color: yellow;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;input type="text" placeholder="Text input"&amp;gt;
    &amp;lt;input type="password" placeholder="Password input"&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Substring Matching(^=):&lt;/strong&gt; It matches elements where the attribute contains a substring.&lt;/p&gt;

&lt;p&gt;Example: Styling links with https in their href.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        a[href^="https"] {
            color: green;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;a href="https://example.com/"&amp;gt;Secure link&amp;lt;/a&amp;gt;
    &amp;lt;a href="http://example.com/"&amp;gt;Non-secure link&amp;lt;/a&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Wildcard Selector (*=):&lt;/strong&gt; Matches elements where the attribute value contains a specific string.&lt;/p&gt;

&lt;p&gt;Example: Underlining links with example in the URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        a[href*="example"] {
            text-decoration: underline;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;a href="https://example.com/"&amp;gt;This contains 'example' and is underlined.&amp;lt;/a&amp;gt;
    &amp;lt;a href="https://otherlink.com"&amp;gt;This is not underlined.&amp;lt;/a&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Ends With Selector ($=):&lt;/strong&gt; Matches elements whose attribute value ends with a specific string.&lt;/p&gt;

&lt;p&gt;Example: Styling links that end with .pdf in their URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;style&amp;gt;
a[href$=".pdf"] {
    color: red;
}
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Word Match Selector (~=): Matches elements whose attribute contains a specific whole word (space-separated).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example: Styling elements that have the class highlight among multiple class names.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;style&amp;gt;
p[class~="highlight"] {
    background: yellow;
}
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Hyphen Match Selector (|=): Matches elements whose attribute value starts with a word followed by a hyphen.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example: Styling elements with language attributes like en or en-US.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;style&amp;gt;
p[lang|="en"] {
    color: blue;
}
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Pseudo-Classes&lt;/strong&gt;&lt;br&gt;
Pseudo-classes in CSS define the special states of elements for styling.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;:hover: Styles elements when the user hovers over them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example: Changing the color of a link when hovered.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        a:hover {
            color: red;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;a href="https://example.com/"&amp;gt;Hover over this to see the effect.&amp;lt;/a&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;:focus: Styles the elements when the user focus on any particular element.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;style&amp;gt;
        input:focus {
            outline: 3px solid red;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;input type="text"&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;:first-child: Styles the element which is the first child of it's parent.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;
    p:first-child {
        color: brown;
    }
&amp;lt;/style&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;Hello1&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;Hello2&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;:last-child: Style's the element which is the last child of it's parent.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;
    p:last-child {
        color:green;
    }
&amp;lt;/style&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;Hello1&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;Hello2&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;:not: Helps to remove a particular element from the styling index or styling context.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;
    p:not(.one) {
        color: blue;
    }
&amp;lt;/style&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;p class="one"&amp;gt;Hello1&amp;lt;/p&amp;gt;
        &amp;lt;p class="two"&amp;gt;Hello2&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Pseudo-Elements&lt;/strong&gt;&lt;br&gt;
Pseudo-elements allow you to target and style specific parts of an element, such as inserting content before or after it.&lt;/p&gt;

&lt;p&gt;They can be used to style parts of text, like the first letter or line of a paragraph.&lt;br&gt;
Pseudo-elements are commonly used to enhance and beautify the internal content of elements.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;::before: To insert some content before an element.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;
    h1::before {
        content: "★ "
    }
&amp;lt;/style&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1 tabindex="0"&amp;gt;Welcome to GFG&amp;lt;/h1&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;::after: To insert some content after an element.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;
    h1::after {
        content: "☀ ";
        color: orangered;
    }
&amp;lt;/style&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1 tabindex="0"&amp;gt;Welcome to GFG&amp;lt;/h1&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;::first-line: Styles the first line of text within a block element. Line breaks mark the beginning of a new line.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;
    p::first-line {
        color: red;
    }
&amp;lt;/style&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;p&amp;gt;Welcome to GFG&amp;lt;br&amp;gt;
        Hello GFG&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;::first-letter: It Styles the first-letter of a word or a sentence.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;
    p::first-letter {
        color: red;
        font-size: 23px;
    }
&amp;lt;/style&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;p&amp;gt;Welcome to GFG&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;::placeholder: Styles the placeholder of a specific input field.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;
    input::placeholder {
        font-size: 20x;
        font-family: sans-serif;
        font-weight: 900;
    }
&amp;lt;/style&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;input type="text" placeholder="Enter your name"&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://www.w3schools.com/css/css_howto.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/css/css_howto.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/css/css-selectors/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/css/css-selectors/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Type_selectors" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Type_selectors&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.programiz.com/css/units" rel="noopener noreferrer"&gt;https://www.programiz.com/css/units&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>frontend</category>
      <category>beginners</category>
      <category>html</category>
    </item>
    <item>
      <title>Class and Pseudo Class</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Mon, 25 May 2026 10:38:33 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/class-and-pseudo-class-3hk9</link>
      <guid>https://dev.to/dev_saravanan_journey/class-and-pseudo-class-3hk9</guid>
      <description>&lt;p&gt;&lt;strong&gt;HTML Class Attribute&lt;/strong&gt;&lt;br&gt;
The class attribute in HTML assigns one or more class names to elements so they can be styled with CSS or manipulated using JavaScript. It helps group elements for consistent design and behavior.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used to apply CSS styles to multiple elements at once.&lt;/li&gt;
&lt;li&gt;Allows JavaScript to select and manipulate elements.&lt;/li&gt;
&lt;li&gt;Supports multiple class names in a single element.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;tag class="classname"&amp;gt;&amp;lt;/tag&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of HTML Class Attribute&lt;/strong&gt;&lt;br&gt;
Here is a basic example of an HTML Class Attribute:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Using the Same Class in Multiple HTML Tags&lt;/strong&gt;&lt;br&gt;
The HTML class attribute can be applied to various tags, allowing multiple elements to share a common classification. This enables consistent styling or functionality across different types of elements, enhancing design cohesion and simplifying maintenance.&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt;: This example shows the use of the classes in HTML.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        &lt;span class="nc"&gt;.country&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"country"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;CHINA&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
        China has the largest population
        in the world.
    &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"country"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;INDIA&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
        India has the second largest
        population in the world.
    &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"country"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;UNITED STATES&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
        United States has the third largest
        population in the world.
    &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In the above example each heading &lt;code&gt;(&amp;lt;h2&amp;gt;)&lt;/code&gt; is assigned the class "country" using the class attribute.&lt;/li&gt;
&lt;li&gt;The CSS selector .country targets multiple elements with the class "country" to apply styling.&lt;/li&gt;
&lt;li&gt;Styling defined for the "country" class is applied uniformly to all headings tagged with it.&lt;/li&gt;
&lt;li&gt;Using class attributes ensures consistent styling across headings, simplifying design management.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Using Multiple Classes on a Single Element&lt;/strong&gt;&lt;br&gt;
HTML allows an element to have multiple classes by separating class names with spaces. This enables a more modular and flexible approach to styling, where an element can share common styles but also have unique styles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: In this example, we will use more than one class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        &lt;span class="nc"&gt;.country&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nc"&gt;.china&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nc"&gt;.india&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nc"&gt;.usa&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nt"&gt;center&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;


&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;center&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"country china"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;CHINA&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"country india"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;INDIA&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"country usa"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;UNITED STATES&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/center&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In the above example &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; elements are assigned the "country" class for shared styling attributes.&lt;/li&gt;
&lt;li&gt;Additional classes like "china", "india", and "usa" provide unique background colors.&lt;/li&gt;
&lt;li&gt;Classes set background colors to black, blue, and red, with white text and padding for visual contrast.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;&amp;lt;center&amp;gt;&lt;/code&gt; tag ensures horizontal alignment of content, improving the presentation and readability of the page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CSS Pseudo-classes&lt;/strong&gt;&lt;br&gt;
A pseudo-class is a keyword added to a CSS selector, prefixed by a colon (:), to define a specific state or condition of an element. It is used to style elements like a hovered button, the first child of a container, or checked input fields.&lt;br&gt;
&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;selector&lt;/span&gt;&lt;span class="nd"&gt;:pseudo-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/* styles */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Interactive/User Action Pseudo-Classes&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. :hover&lt;/strong&gt;&lt;br&gt;
This applies when the user hovers over an element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;lightblue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Hover over me!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will change the background color of the button when hovered over.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. :focus&lt;/strong&gt;&lt;br&gt;
Applies when an element receives focus (e.g., a text input clicked)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Click to focus"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will change the border of the input field to blue when it is focused.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. :active&lt;/strong&gt;&lt;br&gt;
Applies when an element is being clicked.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;darkblue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Click me!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will change the background color of the button when it is being clicked (in the active state).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. :visited&lt;/strong&gt;&lt;br&gt;
Applies to links the user has visited.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:visited&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;purple&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://www.example.com//"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Visit this link&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will change the color of visited links to purple.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. :link&lt;/strong&gt;&lt;br&gt;
Applies to links that the user has not visited yet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:link&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://www.example.com//"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Visit this link&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will make unvisited links appear in green.&lt;/p&gt;

&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/css/css-pseudo-classes/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/css/css-pseudo-classes/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/css/css_pseudo_classes.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/css/css_pseudo_classes.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/html/html-class-attribute/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/html/html-class-attribute/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/html/html_classes.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/html/html_classes.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://pwskills.com/blog/web-development/html-class" rel="noopener noreferrer"&gt;https://pwskills.com/blog/web-development/html-class&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Pseudo-classes" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Pseudo-classes&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>html</category>
      <category>webdev</category>
    </item>
    <item>
      <title>HTML Table Borders</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Fri, 22 May 2026 15:40:26 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/html-table-borders-1jkp</link>
      <guid>https://dev.to/dev_saravanan_journey/html-table-borders-1jkp</guid>
      <description>&lt;p&gt;&lt;strong&gt;HTML Table Borders&lt;/strong&gt;&lt;br&gt;
HTML tables can have borders of different styles and shapes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How To Add a Border&lt;/strong&gt;&lt;br&gt;
To add a border, use the CSS border property on table, th, and td elements:&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;table&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Collapsed Table Borders&lt;/strong&gt;&lt;br&gt;
To avoid having double borders like in the example above, set the CSS border-collapse property to collapse.&lt;/p&gt;

&lt;p&gt;This will make the borders collapse into a single border:&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;table&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-collapse&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;collapse&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Style Table Borders&lt;/strong&gt;&lt;br&gt;
If you set a background color of each cell, and give the border a white color (the same as the document background), you get the impression of an invisible border:&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;table&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-collapse&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;collapse&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#96D4D4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Round Table Borders&lt;/strong&gt;&lt;br&gt;
With the border-radius property, the borders get rounded corners:&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;table&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Skip the border around the table by leaving out table from the css selector:&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Dotted Table Borders&lt;/strong&gt;&lt;br&gt;
With the border-style property, you can set the appearance of the border.&lt;/p&gt;

&lt;p&gt;The following values are allowed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dotted
&lt;/li&gt;
&lt;li&gt;dashed
&lt;/li&gt;
&lt;li&gt;solid
&lt;/li&gt;
&lt;li&gt;double
&lt;/li&gt;
&lt;li&gt;groove
&lt;/li&gt;
&lt;li&gt;ridge
&lt;/li&gt;
&lt;li&gt;inset
&lt;/li&gt;
&lt;li&gt;outset
&lt;/li&gt;
&lt;li&gt;none
&lt;/li&gt;
&lt;li&gt;hidden
Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt; &lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dotted&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;** Border Color**&lt;br&gt;
With the border-color property, you can set the color of the border.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt; &lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#96D4D4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://www.w3schools.com/html/html_table_borders.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/html/html_table_borders.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/html/html-table-border-attribute/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/html/html-table-border-attribute/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Semantic and Non-Semantic elements</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Thu, 21 May 2026 10:17:34 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/semantic-and-non-semantic-elements-44pp</link>
      <guid>https://dev.to/dev_saravanan_journey/semantic-and-non-semantic-elements-44pp</guid>
      <description>&lt;p&gt;&lt;strong&gt;Semantic HTML elements&lt;/strong&gt;&lt;br&gt;
These semantic elements simply mean, elements with meaning. The reason being, there definition in the code tells the browser and the developer what they are supposed to do. Framing in simpler words, these elements describe the type of content they are supposed to contain.&lt;/p&gt;

&lt;p&gt;Following is the list of some semantic elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;article&lt;/li&gt;
&lt;li&gt;aside&lt;/li&gt;
&lt;li&gt;details&lt;/li&gt;
&lt;li&gt;figcaption&lt;/li&gt;
&lt;li&gt;figure&lt;/li&gt;
&lt;li&gt;footer&lt;/li&gt;
&lt;li&gt;form&lt;/li&gt;
&lt;li&gt;header&lt;/li&gt;
&lt;li&gt;main&lt;/li&gt;
&lt;li&gt;mark&lt;/li&gt;
&lt;li&gt;nav&lt;/li&gt;
&lt;li&gt;table&lt;/li&gt;
&lt;li&gt;section&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: This example shows the use of semantic elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;my web page&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nt"&gt;table&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nt"&gt;tr&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nt"&gt;th&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;article&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;GeeksforGeeks&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;A Computer Science Portal for Geeks&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/article&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;head1&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;head2&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;A&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;0&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;B&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;1&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Non-Semantic elements&lt;/strong&gt;&lt;br&gt;
Unlike, semantic elements they don't have any meaning. They don't tell anything about the content they contain. They can be used with different attributes to mark up semantics common to a group.&lt;/p&gt;

&lt;p&gt;Following is the list of some non-semantic elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;div&lt;/li&gt;
&lt;li&gt;span&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: This example shows the use of non-semantic elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;my web page&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;span&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;40px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;span&amp;gt;&lt;/span&gt;GeeksForGeeks&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
        A computer science portal for geeks
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&lt;br&gt;
Difference between semantic and non-semantic elements&lt;br&gt;
Semantic elements   Non-Semantic elements&lt;br&gt;
They have meaning   They don't have meaning&lt;br&gt;
They describe how the content within them is supposed to behave They can contain anything&lt;br&gt;
They have specific attributes for their structure   The 'class' attribute can be used to work with their structure&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://www.geeksforgeeks.org/html/difference-between-semantic-and-non-semantic-elements/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/html/difference-between-semantic-and-non-semantic-elements/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>frontend</category>
      <category>html</category>
      <category>webdev</category>
    </item>
    <item>
      <title>GitHub vs GitLab</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Wed, 20 May 2026 11:14:31 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/github-vs-gitlab-2dap</link>
      <guid>https://dev.to/dev_saravanan_journey/github-vs-gitlab-2dap</guid>
      <description>&lt;p&gt;&lt;strong&gt;GitHub vs GitLab — Which One Should You Use?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Version control platforms are essential for modern development. Two of the most popular choices are GitHub and GitLab. Both are built around Git, but they focus on slightly different goals and workflows.&lt;/p&gt;

&lt;p&gt;This article explains the differences in a simple, practical way with advantages and disadvantages of each.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is GitHub?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub is the world’s most popular code hosting platform, owned by Microsoft.&lt;/li&gt;
&lt;li&gt;It is widely used for open-source projects, personal portfolios, and team collaboration.&lt;/li&gt;
&lt;li&gt;GitHub focuses on simplicity, community, and developer networking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is GitLab?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitLab is a complete DevOps platform that provides source code hosting along with built-in CI/CD, security tools, and deployment features.&lt;/li&gt;
&lt;li&gt;GitLab focuses on the entire software development lifecycle.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;| Feature      | GitHub                            | GitLab                     |&lt;br&gt;
| ------------ | --------------------------------- | -------------------------- |&lt;br&gt;
| Main Focus   | Code hosting &amp;amp; collaboration      | Full DevOps lifecycle      |&lt;br&gt;
| Popularity   | Very high                         | Moderate                   |&lt;br&gt;
| Best for     | Students, open-source, portfolios | Teams, DevOps, enterprises |&lt;br&gt;
| CI/CD        | Good (GitHub Actions)             | Excellent (built-in)       |&lt;br&gt;
| Self-hosting | Limited                           | Strong support             |&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Massive Community&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub hosts millions of repositories and is the default platform for open-source projects.&lt;/li&gt;
&lt;li&gt;Most developers, recruiters, and companies actively use GitHub.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes it ideal for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Showcasing projects&lt;/li&gt;
&lt;li&gt;Networking&lt;/li&gt;
&lt;li&gt;Contributing to open source&lt;/li&gt;
&lt;li&gt;Job hunting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2.Beginner-Friendly Interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitHub has a clean and simple UI that is easy to understand for new developers.&lt;/p&gt;

&lt;p&gt;Learning curve is minimal compared to GitLab.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Strong Portfolio Value&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recruiters often ask for GitHub profiles.&lt;/li&gt;
&lt;li&gt;A strong GitHub profile can directly improve job opportunities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4.Powerful Integrations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitHub integrates easily with many tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VS Code&lt;/li&gt;
&lt;li&gt;Slack&lt;/li&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;li&gt;Cloud platforms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5.GitHub Actions (CI/CD)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitHub provides built-in automation for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;li&gt;Building&lt;/li&gt;
&lt;li&gt;Deploying applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is sufficient for most projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Disadvantages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Limited Built-in DevOps Tools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Advanced DevOps features often require external tools or integrations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Advanced Features Can Be Expensive&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enterprise features and higher CI/CD usage can become costly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Less Built-in Project Management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Compared to GitLab, GitHub has fewer built-in planning tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitLab Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Complete DevOps Platform&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitLab provides an all-in-one solution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Source control&lt;/li&gt;
&lt;li&gt;CI/CD pipelines&lt;/li&gt;
&lt;li&gt;Issue tracking&lt;/li&gt;
&lt;li&gt;Security scanning&lt;/li&gt;
&lt;li&gt;Deployment tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No need for many third-party integrations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.Powerful Built-in CI/CD&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitLab pipelines are available out of the box and are more advanced than GitHub’s default setup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Self-Hosting Option&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Organizations can host GitLab on their own servers for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Privacy&lt;/li&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;li&gt;Compliance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a major advantage for enterprises.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.Better Project Management Tools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitLab includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Issue boards&lt;/li&gt;
&lt;li&gt;Roadmaps&lt;/li&gt;
&lt;li&gt;Milestones&lt;/li&gt;
&lt;li&gt;Time tracking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes it suitable for large teams.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitLab Disadvantages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Smaller Community&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitLab has fewer public repositories and less open-source visibility than GitHub.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.More Complex Interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The platform has many features, which can feel overwhelming for beginners.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Less Recognition for Portfolios&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Recruiters usually expect GitHub links rather than GitLab profiles.&lt;/p&gt;

&lt;p&gt;Collaboration: A Common Myth&lt;/p&gt;

&lt;p&gt;Both GitHub and GitLab allow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unlimited repositories&lt;/li&gt;
&lt;li&gt;Unlimited collaborators&lt;/li&gt;
&lt;li&gt;Large team workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is no restriction like “only 2–3 people per project.”&lt;br&gt;
Teams with dozens or even hundreds of developers use both platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Choose GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Choose GitHub if you are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A student or beginner&lt;/li&gt;
&lt;li&gt;Building a portfolio&lt;/li&gt;
&lt;li&gt;Contributing to open-source projects&lt;/li&gt;
&lt;li&gt;Preparing for job interviews&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GitHub is the best starting point for most developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Choose GitLab&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Choose GitLab if you are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Working in a company environment&lt;/li&gt;
&lt;li&gt;Managing large development teams&lt;/li&gt;
&lt;li&gt;Using CI/CD heavily&lt;/li&gt;
&lt;li&gt;Practicing DevOps workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GitLab is ideal for full project lifecycle management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Verdict&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Both platforms are excellent and built on the same Git foundation.&lt;/p&gt;

&lt;p&gt;GitHub is best for learning, sharing, and career growth.&lt;br&gt;
GitLab is best for DevOps, automation, and enterprise workflows.&lt;/p&gt;

&lt;p&gt;Many developers end up using both during their careers.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>git</category>
      <category>github</category>
      <category>opensource</category>
    </item>
    <item>
      <title>HTML &amp; CSS Beginner Q/A</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Tue, 19 May 2026 10:53:27 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/html-css-beginner-qa-8o7</link>
      <guid>https://dev.to/dev_saravanan_journey/html-css-beginner-qa-8o7</guid>
      <description>&lt;p&gt;&lt;strong&gt;1.What is the purpose of box-sizing: border-box?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By default, CSS uses content-box. That means width/height applies only to the content, and padding + border are added on top, making the element bigger than expected.&lt;/p&gt;

&lt;p&gt;box-sizing: border-box changes this behavior so that:&lt;/p&gt;

&lt;p&gt;Width = content + padding + border&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;code&gt;width: 200px;&lt;br&gt;
padding: 20px;&lt;br&gt;
border: 5px;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Without border-box → total width becomes 250px&lt;br&gt;
With border-box → total width stays 200px&lt;/p&gt;

&lt;p&gt;Why we use it in projects:&lt;/p&gt;

&lt;p&gt;Layout becomes predictable&lt;br&gt;
Easier responsive design&lt;br&gt;
No unexpected overflow issues&lt;/p&gt;

&lt;p&gt;This is why many projects set this globally:&lt;br&gt;
&lt;code&gt;* {&lt;br&gt;
  box-sizing: border-box;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.How does grid-template-columns: 2fr 1fr work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;fr = fraction of available space.&lt;/p&gt;

&lt;p&gt;grid-template-columns: 2fr 1fr means:&lt;/p&gt;

&lt;p&gt;Create two columns&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First column takes 2 parts&lt;/li&gt;
&lt;li&gt;Second column takes 1 part&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the first column is twice as wide as the second.&lt;/p&gt;

&lt;p&gt;Example layout:&lt;br&gt;
&lt;code&gt;|     2/3 width     |   1/3 width   |&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It divides remaining space, not fixed pixels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Difference between semantic tags (&lt;code&gt;&amp;lt;main&amp;gt;, &amp;lt;footer&amp;gt;&lt;/code&gt;) vs &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;&lt;br&gt;
non-semantic tags?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;They describe the meaning of the content.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;main&amp;gt; → main content&lt;br&gt;
&amp;lt;header&amp;gt; → top section&lt;br&gt;
&amp;lt;footer&amp;gt; → bottom section&lt;br&gt;
&amp;lt;nav&amp;gt; → navigation&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better SEO&lt;/li&gt;
&lt;li&gt;Better accessibility (screen readers)&lt;/li&gt;
&lt;li&gt;Cleaner, meaningful code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Has no meaning&lt;/li&gt;
&lt;li&gt;Used only for styling or grouping&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of it like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Semantic tags = labeled boxes&lt;/li&gt;
&lt;li&gt;Div = plain box&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4.Why is vh used instead of px?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;vh = viewport height&lt;br&gt;
1vh = 1% of screen height&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;code&gt;height: 100vh;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Means: element fills entire screen height&lt;/p&gt;

&lt;p&gt;Why use vh?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsive design&lt;/li&gt;
&lt;li&gt;Works on all screen sizes&lt;/li&gt;
&lt;li&gt;Avoids scroll gaps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;px is fixed and does not adapt to screen size.&lt;/p&gt;

&lt;p&gt;Use case:&lt;br&gt;
&lt;code&gt;.hero {&lt;br&gt;
  height: 100vh;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.Difference between Padding and Margin&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Padding&lt;/strong&gt;&lt;br&gt;
Space inside the element (inside border).&lt;br&gt;
&lt;code&gt;| border |&lt;br&gt;
| padding |&lt;br&gt;
| content |&lt;/code&gt;&lt;br&gt;
It pushes content inward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Margin&lt;/strong&gt;&lt;br&gt;
Space outside the element.&lt;/p&gt;

&lt;p&gt;It creates distance between elements.&lt;/p&gt;

&lt;p&gt;Simple memory trick:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Padding = inner space&lt;/li&gt;
&lt;li&gt;Margin = outer space&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6.Difference between Grid and Flexbox&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexbox (1-Dimensional)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Used for layout in one direction&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Row OR Column&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Best for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navbar&lt;/li&gt;
&lt;li&gt;Buttons&lt;/li&gt;
&lt;li&gt;Centering items&lt;/li&gt;
&lt;li&gt;Small layouts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Grid (2-Dimensional)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Used for layout in rows AND columns&lt;/p&gt;

&lt;p&gt;Best for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Page layout&lt;/li&gt;
&lt;li&gt;Dashboards&lt;/li&gt;
&lt;li&gt;Complex sections&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Quick summary:&lt;br&gt;
&lt;code&gt;| Feature   | Flexbox    | Grid         |&lt;br&gt;
| --------- | ---------- | ------------ |&lt;br&gt;
| Direction | 1D         | 2D           |&lt;br&gt;
| Use case  | Components | Page layouts |&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7.What are self-closing tags?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tags that don’t need a closing tag because they don’t wrap content.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;code&gt;&amp;lt;img&amp;gt;&lt;br&gt;
&amp;lt;input&amp;gt;&lt;br&gt;
&amp;lt;br&amp;gt;&lt;br&gt;
&amp;lt;hr&amp;gt;&lt;br&gt;
&amp;lt;meta&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;They insert something instead of containing text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8.Purpose of the meta viewport tag&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This tells the browser:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Match the page width to the device screen&lt;/li&gt;
&lt;li&gt;Do not zoom out like desktop view&lt;/li&gt;
&lt;li&gt;Make the website mobile-friendly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Without this tag:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Website appears zoomed out on phones&lt;/li&gt;
&lt;li&gt;Layout breaks on mobile&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is essential for responsive design.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>html</category>
      <category>webdev</category>
    </item>
    <item>
      <title>HTML Input tag &amp; Gap</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Mon, 18 May 2026 18:10:44 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/html-input-tag-gap-89h</link>
      <guid>https://dev.to/dev_saravanan_journey/html-input-tag-gap-89h</guid>
      <description>&lt;p&gt;&lt;strong&gt;HTML input Tag&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The HTML  tag is used to create interactive form controls that allow users to enter data in a webpage. It supports multiple input types such as text, password, email, number, and more for collecting user information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Input Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;input type="button"&amp;gt;&lt;br&gt;
&amp;lt;input type="checkbox"&amp;gt;&lt;br&gt;
&amp;lt;input type="color"&amp;gt;&lt;br&gt;
&amp;lt;input type="date"&amp;gt;&lt;br&gt;
&amp;lt;input type="datetime-local"&amp;gt;&lt;br&gt;
&amp;lt;input type="email"&amp;gt;&lt;br&gt;
&amp;lt;input type="file"&amp;gt;&lt;br&gt;
&amp;lt;input type="hidden"&amp;gt;&lt;br&gt;
&amp;lt;input type="image"&amp;gt;&lt;br&gt;
&amp;lt;input type="month"&amp;gt;&lt;br&gt;
&amp;lt;input type="number"&amp;gt;&lt;br&gt;
&amp;lt;input type="password"&amp;gt;&lt;br&gt;
&amp;lt;input type="radio"&amp;gt;&lt;br&gt;
&amp;lt;input type="range"&amp;gt;&lt;br&gt;
&amp;lt;input type="reset"&amp;gt;&lt;br&gt;
&amp;lt;input type="search"&amp;gt;&lt;br&gt;
&amp;lt;input type="submit"&amp;gt;&lt;br&gt;
&amp;lt;input type="tel"&amp;gt;&lt;br&gt;
&amp;lt;input type="text"&amp;gt;&lt;br&gt;
&amp;lt;input type="time"&amp;gt;&lt;br&gt;
&amp;lt;input type="url"&amp;gt;&lt;br&gt;
&amp;lt;input type="week"&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In HTML5, elements are divided into types.&lt;br&gt;
&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; belongs to void elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Void elements&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cannot have closing tag&lt;/li&gt;
&lt;li&gt;Cannot have content inside&lt;/li&gt;
&lt;li&gt;They end in the opening tag itself&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;But in day-to-day learning, people often say self-closing tag.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CSS gap Property&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The CSS gap property defines the spacing (or "gap") between rows and columns in layouts such as Flexbox, Grid, or multi-column layouts. It simplifies the process of creating consistent spacing by combining row-gap and column-gap into one property. You can specify the gap using length units (e.g., px, em) or percentages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;gap: &amp;lt;row-gap&amp;gt; &amp;lt;column-gap&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;DIFFERENCE BETWEEN PADDING AND GAP:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Padding&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Padding = space INSIDE an element (inside the border)&lt;/li&gt;
&lt;li&gt;It creates space between the content and the border of that element.&lt;/li&gt;
&lt;li&gt;Think: space inside the box&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;.box{&lt;br&gt;
  padding:20px;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;| border |&lt;br&gt;
|  padding   |&lt;br&gt;
|   content  |&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The text moves away from the border.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Padding belongs to one element only.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gap&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gap = space BETWEEN child elements&lt;/p&gt;

&lt;p&gt;It works only inside:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;flex container&lt;/li&gt;
&lt;li&gt;grid container&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think: space between items&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;.container{&lt;br&gt;
  display:flex;&lt;br&gt;
  gap:20px;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;div class="container"&amp;gt;&lt;br&gt;
  &amp;lt;div&amp;gt;A&amp;lt;/div&amp;gt;&lt;br&gt;
  &amp;lt;div&amp;gt;B&amp;lt;/div&amp;gt;&lt;br&gt;
  &amp;lt;div&amp;gt;C&amp;lt;/div&amp;gt;&lt;br&gt;
&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now space appears between A, B, C.&lt;/p&gt;

&lt;p&gt;Gap belongs to the parent container, not the child.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Easy Visualization&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Padding&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;[  content  ]&lt;br&gt;
^ inside space ^&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gap&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;[A]   [B]   [C]&lt;br&gt;
  ^ between space ^&lt;/code&gt;&lt;/p&gt;

</description>
      <category>gap</category>
      <category>input</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>CSS types &amp; HTML elements</title>
      <dc:creator>Saravanan Lakshmanan</dc:creator>
      <pubDate>Sat, 16 May 2026 07:37:32 +0000</pubDate>
      <link>https://dev.to/dev_saravanan_journey/css-types-html-elements-5g65</link>
      <guid>https://dev.to/dev_saravanan_journey/css-types-html-elements-5g65</guid>
      <description>&lt;p&gt;&lt;strong&gt;Types of CSS (Cascading Style Sheet)&lt;/strong&gt;&lt;br&gt;
CSS is used to style and layout web pages, controlling the appearance of HTML elements. It allows developers to create visually appealing designs and ensure a consistent look across a website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of CSS&lt;/strong&gt;&lt;br&gt;
CSS can be implemented in three different ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Inline CSS&lt;/li&gt;
&lt;li&gt;Internal or Embedded CSS&lt;/li&gt;
&lt;li&gt;External CSS&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1. Inline CSS&lt;/strong&gt;&lt;br&gt;
Inline CSS involves applying styles directly to individual HTML elements using the style attribute. This method allows for specific styling of elements within the HTML document, overriding any external or internal styles.&lt;br&gt;
&lt;strong&gt;2. Internal or Embedded CSS&lt;/strong&gt;&lt;br&gt;
Internal or Embedded CSS is defined within the HTML document’s style element. It applies styles to specified HTML elements. The CSS rule set should be within the HTML file in the head section. In other words, the CSS is embedded inside the style tag within the head section of the HTML file.&lt;br&gt;
&lt;strong&gt;3. External CSS&lt;/strong&gt;&lt;br&gt;
External CSS contains separate CSS files that contain only style properties with the help of tag attributes (For example class, id, heading, ... etc). CSS property is written in a separate file with a .css extension and should be linked to the HTML document using a link tag. It means that, for each element, style can be set only once and will be applied across web pages&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Elements&lt;/strong&gt;&lt;br&gt;
HTML elements are the basic building blocks of a webpage, defining its structure and content using start tags, content, and end tags.&lt;/p&gt;

&lt;p&gt;HTML elements start with an opening tag  and end with a closing tag , and can contain text, attributes, or other nested elements.&lt;br&gt;
Some elements are self-closing (e.g., break tag, image tag), and browsers use elements to render the page visually.&lt;br&gt;
Properly nesting elements ensures valid, accessible, and well-structured HTML.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case Sensitivity&lt;/strong&gt;&lt;br&gt;
HTML tags are not case-sensitive, but using lowercase is recommended for consistency and readability.&lt;/p&gt;

&lt;p&gt;HTML tags are not case-sensitive. For example, B&amp;lt;&amp;gt; and b&amp;lt;&amp;gt; both represent bold text.&lt;br&gt;
However, it’s a best practice to use lowercase tags for consistency and readability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Block-Level Elements and Inline Elements&lt;/strong&gt;&lt;br&gt;
In HTML, elements are broadly categorized into two main types based on how they display in the document layout: block-level elements and inline elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Block-Level Elements&lt;/strong&gt;&lt;br&gt;
Block-level elements start on a new line, occupy the full available width, stack vertically, and can contain both block-level and inline elements.&lt;/p&gt;

&lt;p&gt;Examples&lt;/p&gt;

&lt;p&gt;div tag: A general-purpose container for other elements.&lt;br&gt;
p tag: Defines a paragraph.&lt;br&gt;
h1, h2, h3, h4, h5, h6: Heading elements of different levels.&lt;br&gt;
ol, ul: Ordered and unordered lists.&lt;br&gt;
table: Defines a table.&lt;br&gt;
form: Used for HTML forms to collect user inputs.&lt;br&gt;
section, article, nav, aside, header, footer: Semantic elements that define areas of a webpage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Inline Elements&lt;/strong&gt;&lt;br&gt;
Inline elements do not start on a new line, take only the width of their content, and are used within block-level elements to add or style content.&lt;/p&gt;

&lt;p&gt;span tag: A general-purpose inline container for phrasing content.&lt;br&gt;
a tag: Creates hyperlinks.&lt;br&gt;
img tag: Embeds an image.&lt;br&gt;
strong tag, b tag: Used for strong emphasis and bold text, respectively.&lt;br&gt;
em tag, i tag: Used for emphasis and italic text, respectively.&lt;br&gt;
br tag: Inserts a line break within text.&lt;br&gt;
input tag: Creates interactive controls for forms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tags vs Elements vs Attributes in HTML&lt;/strong&gt;&lt;br&gt;
In HTML, tags represent the structural components of a document, such as h1 tag for headings. Elements are formed by tags and encompass both the opening and closing tags along with the content. Attributes provide additional information or properties to elements, enhancing their functionality or appearance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Tags:&lt;/strong&gt;&lt;br&gt;
HTML tags are the starting and ending parts of an HTML element. They begin with the less-than symbol and end with the greater-than symbol. Whatever is written inside these symbols are called tags.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Elements:&lt;/strong&gt;&lt;br&gt;
An HTML element consists of both the opening and closing tags along with the content inside those tags. It usually forms the structure used to define the purpose of the tag.&lt;/p&gt;

&lt;p&gt;Example: In this example, b is the starting tag and /b is the ending tag, with content placed inside it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Attributes:&lt;/strong&gt;&lt;br&gt;
HTML attributes are used to define the characteristics of an HTML element. They are always placed in the opening tag of an element and usually provide additional information or styling to the element.&lt;/p&gt;

&lt;p&gt;Example: In this example, p is the starting tag and /p is the ending tag with extra CSS attributes included.&lt;/p&gt;

&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/css/types-of-css-cascading-style-sheet/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/css/types-of-css-cascading-style-sheet/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/html/html-elements/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/html/html-elements/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/html/tags-vs-elements-vs-attributes-in-html/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/html/tags-vs-elements-vs-attributes-in-html/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>viral</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
