惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
G
Google Developers Blog
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
小众软件
小众软件
月光博客
月光博客
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
P
Proofpoint News Feed
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
The Cloudflare Blog
博客园_首页
美团技术团队
大猫的无限游戏
大猫的无限游戏
B
Blog
IT之家
IT之家
Jina AI
Jina AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Understanding HTML & CSS with Simple project
Annapoorani · 2026-05-24 · via DEV Community

Always there is a starting point for anything, here is my starting point where I created my portfolio with deep understanding rather than just copy paste 🫣

Every developer bound to understand why it works, how it works and where it works? Let me elaborate the understanding of my portfolio project with HTML and CSS. Before the exact process, let's understand few new terms here.

MARGIN

  • If you need to give any space outside the box, we can use margin

PADDING

  • If you need to give space inside the box, we can use padding

Who is this box?

-In HTML, a box usually refers to the Box Model used in web pages.

Every HTML element behaves like a rectangular box 📦

Examples:

headings,
paragraphs,
images,
buttons,
divs,

all are treated as boxes by the browser.

A box contains:

Step 1 : To create any webpage, plan the webpage, how it should look
Step 2 : Create an HTML file and write the basic structure first
Step 3 : Add your content one by one.
Step 4 : After adding all contents, create a border for each division/section. Bordering helps well in understanding and styling
Step 5 : Start applying styles using CSS as per your requirement

Below is my code and explanation:

Before styling a webpage, one important thing to know is that every browser has its own default margin and padding. Because of this, webpages may look slightly different in different browsers 😄 Here, I have used Internal CSS.

To remove those default spaces, we commonly use:

*{
margin: 0;
padding: 0;
box-sizing: border-box;
}

Here:

  • * is called the Global Selector because it selects all elements on the webpage.
  • box-sizing: border-box helps maintain proper width and height calculations by including padding and border inside the element’s total size.

Selectors are used to target HTML elements for styling.

Examples:

header{}
h1{}

These are called Element Selectors because they directly target HTML elements.


While designing layouts, as a beginner, we often get confused about spacing and element positions 😄
A simple trick is to first add borders to elements:

border: 1px solid black;

This helps clearly visualize the boundaries of each element.


Now let’s understand Parent and Child relationships in HTML.

Example Structure:

Here:

  • <body> is the parent of <header>
  • <header> is the parent of <h1> and <a>
  • <h1> and <a> are children of <header>

HTML elements mainly belong to two categories:

1. Block Level Elements

Block-level elements occupy the entire width available.

Even if the content is small, they block the whole line.

Examples:

  • <header>
  • <h1>
  • <div>
  • <p>

2. Inline Elements

Inline elements only take the space required by their content.

Examples:

  • <a>
  • <span>
  • <strong>

So, <a> tags sit side by side because they are inline elements 😄


Now let’s meet the <nav> tag!

<nav> stands for Navigation and is used to move from one webpage or section to another.

Example:

The <nav> tag itself is a block-level element, but it usually contains inline elements like anchor (<a>) tags.


To create spacing inside a box, we use Padding.

Example:

header{
padding: 20px;
}

Padding adds space between the content and the border.


To create spacing outside the box, we use Margin.

Example:

h1{
margin: 20px;
}

Margin creates distance between elements.

Margins can also be applied individually:

margin-top
margin-right
margin-bottom
margin-left

If only one value is given, the same margin applies to all four sides.


To underline text, CSS provides the text-decoration property.

Example:

text-decoration: underline;

If you want to remove underlines from links:

a{
text-decoration: none;
}

Hope, building this portfolio website project helped in understanding the basics of web development using HTML and CSS. The project demonstrates how to structure a webpage using HTML elements such as header, section, nav, and footer, while CSS was used to improve the design, layout, spacing, colors, and overall appearance of the website.