<?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: Obasi Lilian U</title>
    <description>The latest articles on DEV Community by Obasi Lilian U (@obasililian59cell).</description>
    <link>https://dev.to/obasililian59cell</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3912717%2Fdcd8c66c-f6c2-4fe5-b374-975822ec2c6e.png</url>
      <title>DEV Community: Obasi Lilian U</title>
      <link>https://dev.to/obasililian59cell</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/obasililian59cell"/>
    <language>en</language>
    <item>
      <title>Understanding State in a Vanilla JavaScript Web App</title>
      <dc:creator>Obasi Lilian U</dc:creator>
      <pubDate>Tue, 22 Sep 2026 13:02:22 +0000</pubDate>
      <link>https://dev.to/obasililian59cell/understanding-state-in-a-vanilla-javascript-web-app-3kh2</link>
      <guid>https://dev.to/obasililian59cell/understanding-state-in-a-vanilla-javascript-web-app-3kh2</guid>
      <description>&lt;p&gt;When I first started building small JavaScript applications, I thought the main challenge was writing the JavaScript.&lt;/p&gt;

&lt;p&gt;I later realized the harder part was understanding what happens to the data while the user interacts with the application.&lt;/p&gt;

&lt;p&gt;A user enters information.&lt;/p&gt;

&lt;p&gt;JavaScript reads it.&lt;/p&gt;

&lt;p&gt;The application stores it.&lt;/p&gt;

&lt;p&gt;The data changes.&lt;/p&gt;

&lt;p&gt;The interface needs to reflect that change.&lt;/p&gt;

&lt;p&gt;This is where the idea of state becomes important.&lt;/p&gt;

&lt;p&gt;What is state?&lt;/p&gt;

&lt;p&gt;In a web application, state is the data the application needs to remember while it is running.&lt;/p&gt;

&lt;p&gt;For example, suppose I am building a simple farm expense tracker.&lt;/p&gt;

&lt;p&gt;I might start with an empty array:&lt;/p&gt;

&lt;p&gt;const expenses = [];&lt;/p&gt;

&lt;p&gt;At this point, the application has no recorded expenses.&lt;/p&gt;

&lt;p&gt;If the user enters:&lt;/p&gt;

&lt;p&gt;Seeds&lt;br&gt;
₦5000&lt;/p&gt;

&lt;p&gt;JavaScript might turn that information into an object:&lt;/p&gt;

&lt;p&gt;const expense = {&lt;br&gt;
  category: "Seeds",&lt;br&gt;
  amount: 5000&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;The object is then added to the array:&lt;/p&gt;

&lt;p&gt;expenses.push(expense);&lt;/p&gt;

&lt;p&gt;The state has changed.&lt;/p&gt;

&lt;p&gt;It is now:&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
  {&lt;br&gt;
    category: "Seeds",&lt;br&gt;
    amount: 5000&lt;br&gt;
  }&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;That array represents information the application needs to remember.&lt;/p&gt;

&lt;p&gt;State is not the interface&lt;/p&gt;

&lt;p&gt;This distinction has helped me understand JavaScript applications better.&lt;/p&gt;

&lt;p&gt;The array is the data.&lt;/p&gt;

&lt;p&gt;The HTML elements displayed on the page are the interface.&lt;/p&gt;

&lt;p&gt;They are related, but they are not the same thing.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;const expenses = [&lt;br&gt;
  {&lt;br&gt;
    category: "Seeds",&lt;br&gt;
    amount: 5000&lt;br&gt;
  }&lt;br&gt;
];&lt;/p&gt;

&lt;p&gt;does not automatically put anything on the screen.&lt;/p&gt;

&lt;p&gt;The browser needs JavaScript to take the current state and update the DOM.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;const expenseList = document.querySelector("#expense-list");&lt;/p&gt;

&lt;p&gt;expenseList.innerHTML = "";&lt;/p&gt;

&lt;p&gt;expenses.forEach(expense =&amp;gt; {&lt;br&gt;
  const item = document.createElement("li");&lt;/p&gt;

&lt;p&gt;item.textContent = &lt;code&gt;${expense.category}: ₦${expense.amount}&lt;/code&gt;;&lt;/p&gt;

&lt;p&gt;expenseList.appendChild(item);&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;The JavaScript reads the state and creates the corresponding interface.&lt;/p&gt;

&lt;p&gt;The basic flow&lt;/p&gt;

&lt;p&gt;The pattern I am learning to recognize is:&lt;/p&gt;

&lt;p&gt;User action&lt;br&gt;
    ↓&lt;br&gt;
JavaScript handles the event&lt;br&gt;
    ↓&lt;br&gt;
Read input&lt;br&gt;
    ↓&lt;br&gt;
Update state&lt;br&gt;
    ↓&lt;br&gt;
Render the state&lt;br&gt;
    ↓&lt;br&gt;
UI reflects the new state&lt;/p&gt;

&lt;p&gt;For example, when a farmer clicks an “Add Expense” button:&lt;/p&gt;

&lt;p&gt;Click&lt;br&gt;
 ↓&lt;br&gt;
Read form values&lt;br&gt;
 ↓&lt;br&gt;
Create expense object&lt;br&gt;
 ↓&lt;br&gt;
Add object to expenses array&lt;br&gt;
 ↓&lt;br&gt;
Render expenses&lt;br&gt;
 ↓&lt;br&gt;
Updated expense appears on screen&lt;/p&gt;

&lt;p&gt;This way of thinking is more useful to me than thinking about each line of JavaScript in isolation.&lt;/p&gt;

&lt;p&gt;Why rendering matters&lt;/p&gt;

&lt;p&gt;Suppose I update the array:&lt;/p&gt;

&lt;p&gt;expenses.push(expense);&lt;/p&gt;

&lt;p&gt;but do not update the interface.&lt;/p&gt;

&lt;p&gt;The data has changed, but the user will not see the new expense.&lt;/p&gt;

&lt;p&gt;This is an important distinction.&lt;/p&gt;

&lt;p&gt;Changing the data does not automatically mean changing the DOM.&lt;/p&gt;

&lt;p&gt;I need to explicitly render the updated state.&lt;/p&gt;

&lt;p&gt;A simple render function might look like this:&lt;/p&gt;

&lt;p&gt;function renderExpenses() {&lt;br&gt;
  expenseList.innerHTML = "";&lt;/p&gt;

&lt;p&gt;expenses.forEach(expense =&amp;gt; {&lt;br&gt;
    const item = document.createElement("li");&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;item.textContent = `${expense.category}: ₦${expense.amount}`;

expenseList.appendChild(item);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;});&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Then after changing the state:&lt;/p&gt;

&lt;p&gt;expenses.push(expense);&lt;/p&gt;

&lt;p&gt;renderExpenses();&lt;/p&gt;

&lt;p&gt;The sequence becomes easier to follow.&lt;/p&gt;

&lt;p&gt;First, change the data.&lt;/p&gt;

&lt;p&gt;Then, update the interface.&lt;/p&gt;

&lt;p&gt;Where localStorage fits&lt;/p&gt;

&lt;p&gt;There is another part of the process when the application needs to remember data after the browser is refreshed.&lt;/p&gt;

&lt;p&gt;An in-memory array disappears when the page is reloaded.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;const expenses = [];&lt;/p&gt;

&lt;p&gt;starts again as an empty array when the application loads.&lt;/p&gt;

&lt;p&gt;localStorage gives the application a way to persist the data in the browser.&lt;/p&gt;

&lt;p&gt;A simplified example:&lt;/p&gt;

&lt;p&gt;localStorage.setItem(&lt;br&gt;
  "expenses",&lt;br&gt;
  JSON.stringify(expenses)&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;When the application starts again, the stored data can be retrieved:&lt;/p&gt;

&lt;p&gt;const savedExpenses = localStorage.getItem("expenses");&lt;/p&gt;

&lt;p&gt;const expenses = savedExpenses&lt;br&gt;
  ? JSON.parse(savedExpenses)&lt;br&gt;
  : [];&lt;/p&gt;

&lt;p&gt;Now the application has another part of the flow:&lt;/p&gt;

&lt;p&gt;User action&lt;br&gt;
    ↓&lt;br&gt;
Update state&lt;br&gt;
    ↓&lt;br&gt;
Save state&lt;br&gt;
    ↓&lt;br&gt;
Render state&lt;/p&gt;

&lt;p&gt;And when the application loads:&lt;/p&gt;

&lt;p&gt;Load saved data&lt;br&gt;
    ↓&lt;br&gt;
Create current state&lt;br&gt;
    ↓&lt;br&gt;
Render state&lt;/p&gt;

&lt;p&gt;What I am starting to understand&lt;/p&gt;

&lt;p&gt;Building small applications has changed how I think about JavaScript.&lt;/p&gt;

&lt;p&gt;Instead of asking:&lt;/p&gt;

&lt;p&gt;“Which JavaScript method do I need?”&lt;/p&gt;

&lt;p&gt;I am starting to ask:&lt;/p&gt;

&lt;p&gt;“What data does the application need to remember?”&lt;/p&gt;

&lt;p&gt;“What event changes that data?”&lt;/p&gt;

&lt;p&gt;“How should the interface represent the current data?”&lt;/p&gt;

&lt;p&gt;“Does the data need to survive a page refresh?”&lt;/p&gt;

&lt;p&gt;These questions lead to better implementation decisions.&lt;/p&gt;

&lt;p&gt;I am still building with vanilla HTML, CSS, and JavaScript, but I am beginning to see the structure behind interactive web applications.&lt;/p&gt;

&lt;p&gt;The syntax is important.&lt;/p&gt;

&lt;p&gt;Understanding the flow of data is equally important.&lt;/p&gt;

&lt;p&gt;That is the part I am focusing on now.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Building an Interactive Plant Album with Zero JavaScript</title>
      <dc:creator>Obasi Lilian U</dc:creator>
      <pubDate>Fri, 22 May 2026 13:17:23 +0000</pubDate>
      <link>https://dev.to/obasililian59cell/building-an-interactive-plant-album-with-zero-javascript-2oof</link>
      <guid>https://dev.to/obasililian59cell/building-an-interactive-plant-album-with-zero-javascript-2oof</guid>
      <description>&lt;p&gt;Subtitle: How I used CSS &lt;code&gt;:target&lt;/code&gt;, viewport units, and image optimization to ship a performant, JavaScript-free project.&lt;/p&gt;

&lt;p&gt;I’ve posted on Dev.to before about concepts I’m learning, but this is different. This is the first time I’m sharing a complete, shipped project,  one that bridges my past life as an agricultural scientist with my new path in frontend development.&lt;/p&gt;

&lt;p&gt;Meet the Plant Photo Album: an interactive guide to 27 plants, built entirely with semantic HTML and pure CSS. No JavaScript. No frameworks. Just clean code and a lot of problem-solving.&lt;/p&gt;

&lt;p&gt;The Goal: Interactivity Without JavaScript&lt;/p&gt;

&lt;p&gt;I wanted users to tap a plant name and see only that plant’s details, hiding everything else. My first instinct was to reach for JavaScript, but I challenged myself: Can I do this with CSS alone?&lt;/p&gt;

&lt;p&gt;The answer was yes, using the &lt;code&gt;:target&lt;/code&gt; pseudo-class.&lt;/p&gt;

&lt;p&gt;Here’s the core logic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each plant lives in its own &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; with a unique ID (e.g., &lt;code&gt;#carrot&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;By default, all sections are hidden (&lt;code&gt;display: none&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;When a link is clicked, the URL hash changes (e.g., &lt;code&gt;#carrot&lt;/code&gt;), and the matching section becomes visible (&lt;code&gt;section:target { display: block; }&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s a simple trick, but it creates a seamless, app-like feel without a single line of JavaScript.&lt;/p&gt;

&lt;p&gt;The Hurdle: When “It Works” Isn’t Enough&lt;/p&gt;

&lt;p&gt;The structure was solid. The navigation worked. But when I tested it on mobile, the images were crawling, some taking seconds to load, others failing completely.&lt;/p&gt;

&lt;p&gt;I initially blamed my CSS. Were viewport units (&lt;code&gt;vh&lt;/code&gt;/&lt;code&gt;vw&lt;/code&gt;) causing reflows? Was the display logic too heavy?&lt;/p&gt;

&lt;p&gt;Then I checked the file sizes.&lt;/p&gt;

&lt;p&gt;Some images were 7–9MB. I had pulled high-resolution photos directly from my camera roll and uploaded them as-is. Of course it was slow. The browser had to download massive files before resizing them for a phone screen.&lt;/p&gt;

&lt;p&gt;The Fix: Compression Matters&lt;/p&gt;

&lt;p&gt;I pulled all 27 images down, ran them through Squoosh.app (and TinyPNG for a few), and compressed them to 200–600KB each. The visual quality stayed sharp, but the load times dropped dramatically.&lt;/p&gt;

&lt;p&gt;Lesson learned: Performance isn’t just about code. It’s about assets. A beautiful layout means nothing if the user is staring at a loading spinner.&lt;/p&gt;

&lt;p&gt;The Result&lt;/p&gt;

&lt;p&gt;Now, the album loads smoothly on mobile. Users can tap through 27 plants, from carrots to baobab trees, with instant transitions. The entire project is under 500 lines of code, fully responsive, and live in my portfolio.&lt;/p&gt;

&lt;p&gt;What I Learned&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;CSS is more powerful than I gave it credit for. The &lt;code&gt;:target&lt;/code&gt; pseudo-class handled complex state changes without JS.&lt;/li&gt;
&lt;li&gt;Optimization is part of the build. Don’t wait until the end to check file sizes.&lt;/li&gt;
&lt;li&gt;Your background is an asset. My knowledge of plants helped me curate accurate content, and my debugging skills helped me ship a performant product.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This project reminded me that transitioning careers doesn’t mean leaving your past behind. It means bringing it with you, in this case, literally, from garden to glass.&lt;/p&gt;

&lt;p&gt;You can check out the live demo and code on my portfolio : &lt;a href="https://obasililian59-cell.github.io/Web-development-portfolio/plant.html" rel="noopener noreferrer"&gt;https://obasililian59-cell.github.io/Web-development-portfolio/plant.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>learning</category>
      <category>css</category>
    </item>
    <item>
      <title>Week 2 in Frontend: Layout, Structure &amp; New Insights</title>
      <dc:creator>Obasi Lilian U</dc:creator>
      <pubDate>Sun, 17 May 2026 11:09:19 +0000</pubDate>
      <link>https://dev.to/obasililian59cell/week-2-in-frontend-layout-structure-new-insights-38ab</link>
      <guid>https://dev.to/obasililian59cell/week-2-in-frontend-layout-structure-new-insights-38ab</guid>
      <description>&lt;p&gt;I spent the previous week deepening my understanding of how layout actually works in CSS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Continued studying and practicing CSS units (ems, rems, vh/vw), with a focus on how relative units respond to font size and viewport changes.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Practiced switching between pixel and percentage units to observe fixed vs flexible sizing behavior hands‑on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Discovered why CSS &lt;code&gt;margin‑left&lt;/code&gt; worked visually but didn't feel structurally right, and instead restructured the element hierarchy to solve it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explored the &lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt; element, learned that it's hidden by default (unless the &lt;code&gt;open&lt;/code&gt; attribute is present), and used it to build a reusable newsletter form dialog.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wrote about design concepts like hierarchy, contrast, color, and whitespace without prior vocabulary, then named them and refined my eye for layout.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Last week reinforced that structure decides everything; content, spacing, and visual hierarchy far more than quick fixes like margins do.&lt;/p&gt;

&lt;p&gt;What I learned: CSS isn't abstract. It reveals itself through behavior, not theory alone. Fixing layout issues becomes easier when you ask, "Where did this element belong?"&lt;/p&gt;

</description>
      <category>web</category>
      <category>frontend</category>
      <category>css</category>
      <category>buildinpublic</category>
    </item>
    <item>
      <title>Week 1: Gradients, SVGs, and the Art of Consistency (#100DaysOfCode)</title>
      <dc:creator>Obasi Lilian U</dc:creator>
      <pubDate>Sun, 10 May 2026 10:45:47 +0000</pubDate>
      <link>https://dev.to/obasililian59cell/week-1-gradients-svgs-and-the-art-of-consistency-100daysofcode-46fl</link>
      <guid>https://dev.to/obasililian59cell/week-1-gradients-svgs-and-the-art-of-consistency-100daysofcode-46fl</guid>
      <description>&lt;p&gt;Status:  ✅ Complete&lt;br&gt;&lt;br&gt;
Focus: CSS Backgrounds, Borders, SVG Basics, Iframes&lt;br&gt;&lt;br&gt;
Project Highlight: The Digital Art Frame. &lt;/p&gt;

&lt;p&gt;🛠 What I Built&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Savannah Brew Menu (Live Demo)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A fully responsive café menu page.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Key Tech: Semantic HTML, CSS Grid/Inline-block, Warm Color Palette (&lt;code&gt;#F3EDE6&lt;/code&gt;, &lt;code&gt;#E8DDD0&lt;/code&gt;).  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Win: Successfully embedded live via GitHub Pages and added icons using HTML entities.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Link: &lt;a href="https://obasililian59-cell.github.io/Web-development-portfolio/savannah-brew-menu.html" rel="noopener noreferrer"&gt;Savannah Brew Menu&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;The Digital Art Frame&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A compositional experiment to test layering.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Key Tech: Linear Gradients, SVG Shapes (&lt;code&gt;&amp;lt;rect&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;circle&amp;gt;&lt;/code&gt;), Iframes. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Challenge: Positioning an iframe under an SVG frame without Flexbox (solved with negative margins for now).  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lesson: SVG is just a coordinate system, not magic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Portfolio Refinement&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Spent time tweaking spacing on existing projects.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Focus: Margins, padding, and border consistency.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Decision: Identified layout issues I’ll fix once I learn Flexbox (managing technical debt).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🧠 Key Takeaways&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;SVG Coordinates: Learned that &lt;code&gt;cx&lt;/code&gt;, &lt;code&gt;cy&lt;/code&gt;, and &lt;code&gt;r&lt;/code&gt; are just math instructions for position and size. Experimenting with numbers made it click faster than theory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Layering Context: Understanding how &lt;code&gt;z-index&lt;/code&gt; and negative margins interact to create overlapping effects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Consistency &amp;gt; Intensity: Posting daily on X, even with small updates, keeps the momentum going without burnout.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Technical Debt: It’s okay to leave a “good enough” fix in place if you know why it’s not perfect and have a plan to refactor later.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🚧 Challenges &amp;amp; Solutions&lt;br&gt;
At first, SVG shapes appeared as text, then I realized I saved the file as &lt;code&gt;.txt&lt;/code&gt; instead of &lt;code&gt;.html&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;When my text was not centering vertically in a div, I used &lt;code&gt;padding-top&lt;/code&gt; for moment; flagged Flexbox as the future fix. &lt;/p&gt;

&lt;p&gt;I actually felt overwhelmed by new concepts but then broke them down into tiny experiments (e.g., changing one coordinate at a time). &lt;/p&gt;

&lt;p&gt;🏪Next Week’s Plan&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Learning: Diving into Design Principles in CSS course.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Building: Continue refining portfolio spacing and typography.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Habit: Maintain daily X posts + Sunday Dev.to wrap-ups.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💬 Final Thought&lt;br&gt;
"&lt;em&gt;You don’t have to see the whole staircase. Just take the first step&lt;/em&gt;."&lt;br&gt;&lt;br&gt;
This week proved that small, consistent experiments build confidence faster than waiting for perfection.&lt;br&gt;
See you in Week 2! 👋&lt;/p&gt;

</description>
      <category>learning</category>
      <category>100daysofcode</category>
      <category>webdev</category>
      <category>buildinpublic</category>
    </item>
    <item>
      <title>From Negative Margins to Clean Layouts: How I Stopped Fighting CSS</title>
      <dc:creator>Obasi Lilian U</dc:creator>
      <pubDate>Mon, 04 May 2026 20:10:15 +0000</pubDate>
      <link>https://dev.to/obasililian59cell/from-negative-margins-to-clean-layouts-how-i-stopped-fighting-css-15hd</link>
      <guid>https://dev.to/obasililian59cell/from-negative-margins-to-clean-layouts-how-i-stopped-fighting-css-15hd</guid>
      <description>&lt;p&gt;Hi everyone! 👋&lt;/p&gt;

&lt;p&gt;I'm Lilian, a frontend developer transitioning from Agricultural Science. This week, I launched my first professional portfolio hub, and I want to share a specific lesson I learned about CSS spacing that changed how I approach layouts.&lt;/p&gt;

&lt;p&gt;The Problem: Forcing Things to Fit&lt;/p&gt;

&lt;p&gt;When I was styling my portfolio, I noticed some elements felt too far apart. My quick fix? Negative margins.&lt;/p&gt;

&lt;p&gt;I wrote code like this:&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;blockquote&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;margin-top&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="c"&gt;/* Pulling it up by force */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On my desktop screen, it looked perfect. But when I checked it on mobile, things started overlapping unpredictably. I was essentially "pulling elements upward by force" instead of letting them flow naturally.&lt;/p&gt;

&lt;p&gt;The Realization&lt;/p&gt;

&lt;p&gt;I realized that negative margins are often a shortcut that fights the document flow. They might solve a visual problem in one specific view, but they break easily when the screen size changes.&lt;/p&gt;

&lt;p&gt;The Solution: Working With the Flow&lt;/p&gt;

&lt;p&gt;Instead of forcing elements to move, I learned to adjust the natural spacing of the elements around them.&lt;/p&gt;

&lt;p&gt;The "pro move" I discovered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce the &lt;code&gt;margin-bottom&lt;/code&gt; of the element above.&lt;/li&gt;
&lt;li&gt;Or reduce the &lt;code&gt;margin-top&lt;/code&gt; of the element below.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So instead of this:&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="c"&gt;/* ❌ The old way */&lt;/span&gt;
&lt;span class="nt"&gt;blockquote&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;margin-top&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I did this:&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="c"&gt;/* ✅ The new way */&lt;/span&gt;
&lt;span class="nc"&gt;.intro-section&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;margin-bottom&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="c"&gt;/* Gentle spacing */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="nt"&gt;blockquote&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;margin-top&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="c"&gt;/* Natural flow */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Result&lt;/p&gt;

&lt;p&gt;My layout is now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Stable on all screen sizes.&lt;/li&gt;
&lt;li&gt;✅ Easier to maintain.&lt;/li&gt;
&lt;li&gt;✅ Predictable when I add new content.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Takeaway&lt;/p&gt;

&lt;p&gt;If you find yourself using negative margins to fix spacing, pause. Ask yourself: Am I fighting the flow?&lt;/p&gt;

&lt;p&gt;Often, the solution isn't to pull harder, but to adjust the space around the elements gently.&lt;/p&gt;

&lt;p&gt;You can see the final result of this lesson in my live portfolio here:&lt;br&gt;
🔗 &lt;a href="https://obasililian59-cell.github.io/Web-development-portfolio/" rel="noopener noreferrer"&gt;Web Development Portfolio Hub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm still learning, but sharing these small wins helps me remember them. Thanks for reading!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>css</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
