Web Development
79.3K subscribers
1.4K photos
1 video
2 files
739 links
Learn Web Development From Scratch

0️⃣ HTML / CSS
1️⃣ JavaScript
2️⃣ React / Vue / Angular
3️⃣ Node.js / Express
4️⃣ REST API
5️⃣ SQL / NoSQL Databases
6️⃣ UI / UX Design
7️⃣ Git / GitHub

Admin: @love_data
Download Telegram
Which of the following is a valid HEX color code for red?
Anonymous Quiz
45%
19%
18%
Which CSS property adds an image as an element's background?
Anonymous Quiz
12%
A) background-color
20%
B) image-src
62%
C) background-image
6%
D) img-background
What is the alpha value for 50% opacity in RGBA?
Anonymous Quiz
5%
A) 0
80%
B) 0.5
7%
C) 1
8%
D) 50
❤2
𝗝.𝗣. 𝗠𝗢𝗥𝗚𝗔𝗡 𝗙𝗥𝗘𝗘 𝗩𝗜𝗥𝗧𝗨𝗔𝗟 𝗣𝗥𝗢𝗚𝗥𝗔𝗠𝗦 𝟮𝟬𝟮𝟲! 🎓

Explore J.P. Morgan's FREE Virtual Job Simulation Programs

✅ 100% FREE Virtual Learning
✅ Work on Practical, Industry-Based Tasks
✅ Learn at Your Own Pace
✅ Build Valuable Professional Skills

🎯 Perfect For:- College Students | Freshers | Graduates | Job Seekers

🔗 𝗟𝗶𝗻𝗸 👇:-

https://pdlink.in/3X8KJmE

⚡ Learn New Skills • Gain Practical Exposure • Boost Your Career!
❤5
🚀 𝗗𝗮𝘁𝗮 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝘂𝗿𝘀𝗲 📊

Learn Excel, SQL, Python & Power BI Live Online Data Analytics Program

💰 Highest Salary: ₹12.6 LPA
📈 Average Salary: ₹5.7 LPA
🏢 500+ Partner Companies

𝗔𝗽𝗽𝗹𝘆 𝗡𝗼𝘄👇 :-

https://pdlink.in/45vk5ph

🔥 Turn your interest in data into practical, job-ready skills!
🌐 Web Development Roadmap, Part 27

CSS Units (px, %, em, rem, vh, vw and fr)

CSS units define the size of elements, text, spacing, widths, heights, and layouts.

For example, when you write:

h1 {
font-size: 32px;
}
The px defines the size of the heading.

CSS units are divided into two main categories:

• Absolute units
• Relative units

1. Pixels (px)

Pixels are commonly used to define fixed sizes.

.box {
width: 300px;
height: 200px;
padding: 20px;
}
Here:

• Width = 300 pixels
• Height = 200 pixels
• Padding = 20 pixels

Use pixels when you need a specific size.

2. Percentage (%)

Percentage defines a size relative to the parent element's corresponding dimension.

<div class="parent">
<div class="child">Hello</div>
</div>
`
.parent {
width: 600px;
}

.child {
width: 50%;
}

The child width will be 300px because it is 50% of its parent's 600px width.

3. EM (em)

em is a relative unit.

For font size, it is calculated relative to the inherited font size of the parent.

.parent {
font-size: 20px;
}

.child {
font-size: 2em;
}

The child font size becomes 40px.

Calculation:

20px × 2 = 40px

Note: For properties such as padding and margin, em is based on the font size of the element itself.

4. REM (rem)

rem stands for Root EM.

It is calculated relative to the font size of the root HTML element.

By default, browsers generally use 16px as the root font size.

html {
font-size: 16px;
}

h1 {
font-size: 2rem;
}


16px × 2 = 32px

So the heading will have a font size of 32px.

Difference between em and rem:

• em depends on the relevant element's inherited or own font size, depending on the property.
• rem depends on the root HTML font size.

5. Viewport Height (vh)

vh represents a percentage of the viewport height.

1vh = 1% of viewport height.

.hero {
height: 100vh;
}

This makes the element as tall as the viewport.

Useful for:

• Full-screen sections
• Landing pages
• Hero sections

6. Viewport Width (vw)

vw represents a percentage of the viewport width.

1vw = 1% of viewport width.

.container {
width: 80vw;
}

This makes the container 80% of the viewport width.

• Responsive layouts
• Full-width sections
• Flexible sizing

7. FR Unit

fr stands for fractional unit.

It is mainly used with CSS Grid to divide available space into fractions.

.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}

This creates three equal-width columns.

Another example:

.container {
display: grid;
grid-template-columns: 2fr 1fr;
}

The first column gets twice the available space of the second column.

8. Other CSS Units

Some additional units you should know:

• cm, Centimeters
• mm, Millimeters
• in, Inches
• pt, Points
• pc, Picas
• vmin, 1% of the smaller viewport dimension
• vmax, 1% of the larger viewport dimension
• ch, Based on the width of the "0" character
• ex, Based on the x-height of the font

9. Practical Example

Let's create a responsive card using different CSS units.

HTML:

<div class="card">
<h2>Learn Web Development</h2>
<p>Start learning HTML, CSS and JavaScript.</p>
</div>

CSS:

.card {
width: 80%;
max-width: 500px;
padding: 2rem;
margin: 5vh auto;
background-color: lightblue;
border-radius: 1rem;
}

.card h2 {
font-size: 2rem;
}

.card p {
font-size: 1rem;
}

`

This example combines percentages, pixels, rem, and vh to create a flexible layout.

10. Quick Comparison

• px: Meaning Pixels · Common usage Fixed sizing
• %: Meaning Percentage · Common usage Relative sizing
• em: Meaning Relative to font size · Common usage Text and spacing
❤5
- rem: Meaning Relative to root font size · Common usage Consistent typography
- vh: Meaning Viewport height · Common usage Full-screen sections
- vw: Meaning Viewport width · Common usage Responsive widths
- fr: Meaning Fraction · Common usage CSS Grid layouts

Key Takeaways

- Use
px

for fixed dimensions.

- Use
%

for relative sizing.

- Use
em

and
rem

for scalable typography and spacing.

- Use
vh

and
vw

for viewport-based sizing.

- Use
fr

to divide available space in CSS Grid.

Understanding CSS units is essential for creating responsive websites that work across mobile phones, tablets, and desktops.

Double Tap ❤️ For More
❤13
Which CSS unit represents pixels?
Anonymous Quiz
4%
A) rem
90%
B) px
6%
C) em
0%
D) vh
❤2
By default, what is the root font size in most browsers?
Anonymous Quiz
18%
A) 10px
39%
B) 12px
39%
C) 16px
4%
D) 20px
Which unit is commonly used with CSS Grid to divide available space?
Anonymous Quiz
23%
A) px
16%
B) em
44%
C) fr
16%
D) rem
If the parent font size is 20px, what is 2em for a child’s font size?
Anonymous Quiz
19%
A) 20px
15%
B) 30px
61%
C) 40px
5%
D) 60px
If the root font size is 16px, what is 2rem?
Anonymous Quiz
9%
A) 16px
18%
B) 24px
70%
C) 32px
2%
D) 40px
Which CSS unit represents 1% of the viewport width?
Anonymous Quiz
19%
A) vh
56%
B) vw
17%
C) fr
8%
D) em
❤4
🚀 𝗔𝗜 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝘂𝗿𝘀𝗲 😍| 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮𝗻 𝗔𝗜 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿

This AI engineering course online is structured around AI fundamentals, full-stack development, real-world AI projects

💫2000+ Students Placed
🎥 Live Classes + Session Recordings
👨‍💻 1:1 Mentorship & Doubt Support
💼 Interview Preparation & Placement Assistance

𝗕𝗼𝗼𝗸 𝗮 𝗙𝗥𝗘𝗘 𝗗𝗲𝗺𝗼👇:-
​
https://pdlink.in/4fWJVID

🔥 Take the next step towards building your career in AI!
❤1
🌐 Web Development Roadmap — Part 28

CSS Text & Fonts

CSS text and font properties help you control how text looks on a webpage.

You can change font styles, sizes, thickness, alignment, spacing, and decoration.

1. font-family

The font-family property defines which font is displayed.

h1 {
font-family: Arial, sans-serif;
}

p {
font-family: Georgia, serif;
}


Common font families:

• Arial
• Times New Roman
• Georgia
• Verdana
• Courier New
• Tahoma

You can also provide fallback fonts:

body {
font-family: Arial, Helvetica, sans-serif;
}


If the first font isn't available, the browser tries the next one.

2. font-size

Controls the size of the text.

h1 {
font-size: 32px;
}

p {
font-size: 18px;
}


You can use different units such as px, em, and rem.

3. font-weight

Controls how thick or bold the text appears.

h1 {
font-weight: bold;
}

p {
font-weight: normal;
}


Common values:


+-------+------------+
| Value | Meaning |
+-------+------------+
| 100 | Thin |
| 300 | Light |
| 400 | Normal |
| 500 | Medium |
| 600 | Semi-bold |
| 700 | Bold |
| 900 | Extra bold |
+-------+------------+


The availability of each weight depends on the font.

4. font-style

Controls whether text appears normal, italic, or oblique.

p {
font-style: italic;
}


Common values:

• normal
• italic
• oblique

5. text-align

Controls the horizontal alignment of text.

h1 {
text-align: center;
}


Common values:

text-align: left;
text-align: right;
text-align: center;
text-align: justify;


6. text-decoration

Adds or removes decorative lines from text.

h1 {
text-decoration: underline;
}


Common values:

• underline – Line below text
• overline – Line above text
• line-through – Line through text
• none – Removes decoration

Example:

a {
text-decoration: none;
}


This is commonly used to remove the default underline from links.

7. text-transform

Controls the capitalization of text.

.uppercase {
text-transform: uppercase;
}

.lowercase {
text-transform: lowercase;
}

.capitalize {
text-transform: capitalize;
}


For example, hello world becomes:

• Uppercase: HELLO WORLD
• Lowercase: hello world
• Capitalize: Hello World

8. line-height

Controls the vertical space between lines of text.

p {
line-height: 1.6;
}


A suitable line height makes paragraphs easier to read.

9. letter-spacing

Controls the spacing between individual characters.

h1 {
letter-spacing: 2px;
}


10. word-spacing

Controls the spacing between words.

p {
word-spacing: 5px;
}


11. text-indent

Adds indentation to the first line of a paragraph.

p {
text-indent: 30px;
}


12. Google Fonts

Google Fonts provides a large collection of fonts that you can use in websites.

For example, you can use the Roboto font.

Add this inside the HTML <head>:

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">


Then apply it using CSS:

body {
font-family: "Roboto", sans-serif;
}


13. Real-World Example

Let's design a simple heading and paragraph.

HTML:

<div class="content">
<h1>Learn Web Development</h1>

<p>
Start your journey with HTML, CSS and JavaScript.
</p>
</div>


CSS:

.content {
font-family: Arial, sans-serif;
text-align: center;
}

h1 {
font-size: 32px;
font-weight: 700;
color: blue;
letter-spacing: 1px;
}

p {
font-size: 18px;
line-height: 1.6;
color: gray;
}


This creates a clean heading and readable paragraph.

Double Tap ❤️ For Part-29
❤4👍3