Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 2, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 2, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 2, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 2, 2025

      The Alters: Release date, mechanics, and everything else you need to know

      June 2, 2025

      I’ve fallen hard for Starsand Island, a promising anime-style life sim bringing Ghibli vibes to Xbox and PC later this year

      June 2, 2025

      This new official Xbox 4TB storage card costs almost as much as the Xbox SeriesXitself

      June 2, 2025

      I may have found the ultimate monitor for conferencing and productivity, but it has a few weaknesses

      June 2, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      May report 2025

      June 2, 2025
      Recent

      May report 2025

      June 2, 2025

      Write more reliable JavaScript with optional chaining

      June 2, 2025

      Deploying a Scalable Next.js App on Vercel – A Step-by-Step Guide

      June 2, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      The Alters: Release date, mechanics, and everything else you need to know

      June 2, 2025
      Recent

      The Alters: Release date, mechanics, and everything else you need to know

      June 2, 2025

      I’ve fallen hard for Starsand Island, a promising anime-style life sim bringing Ghibli vibes to Xbox and PC later this year

      June 2, 2025

      This new official Xbox 4TB storage card costs almost as much as the Xbox SeriesXitself

      June 2, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»Handwriting an SVG Heart, With Our Hearts

    Handwriting an SVG Heart, With Our Hearts

    February 14, 2025

    According to local grocery stores, it’s the Valentine’s Day season again, and what better way to express our love than with the symbol of love: a heart. A while back on CSS-Tricks, we shared several ways to draw hearts, and the response was dreamy. Check out all these amazing, heart-filled submissions in this collection on CodePen:

    Temani Afif’s CSS Shapes site offers a super modern heart using only CSS:

    CodePen Embed Fallback

    Now, to show my love, I wanted to do something personal, something crafty, something with a mild amount of effort.

    L is for Love Lines

    Handwriting a love note is a classic romantic gesture, but have you considered handwriting an SVG? We won’t need some fancy vector drawing tool to express our love. Instead, we can open a blank HTML document and add an <svg> tag:

    <svg>
    
    </svg>

    We’ll need a way to see what we are doing inside the “SVG realm” (as I like to call it), which is what the viewBox attribute provides. The 2D plane upon which vector graphics render is as infinite as our love, quite literally, complete with an x- and y-axis and all (like from math class).

    We’ll set the start coordinates as 0 0 and end coordinates as 10 10 to make a handsome, square viewBox. Oh, and by the way, we don’t concern ourselves over pixels, rem values, or any other unit types; this is vector graphics, and we play by our own rules.

    diagram depicting a viewbox drawn on a graph

    We add in these coordinates to the viewBox as a string of values:

    <svg viewBox="0 0 10 10">
    
    </svg>

    Now we can begin drawing our heart, with our heart. Let’s make a line. To do that, we’ll need to know a lot more about coordinates, and where to stick ’em. We’re able to draw a line with many points using the <path> element, which defines paths using the d attribute. SVG path commands are difficult to memorize, but the effort means you care. The path commands are:

    • MoveTo: M, m
    • LineTo: L, l, H, h, V, v
    • Cubic Bézier curve: C, c, S, s
    • Quadratic Bézier Curve: Q, q, T, t
    • Elliptical arc curve: A, a
    • ClosePath: Z, z

    We’re only interested in drawing line segments for now, so together we’ll explore the first two: MoveTo and LineTo. MDN romantically describes MoveTo as picking up a drawing instrument, such as a pen or pencil: we aren’t yet drawing anything, just moving our pen to the point where we want to begin our confession of love.

    We’ll MoveTo (M) the coordinates of (2,2) represented in the d attribute as M2,2:

    <svg viewBox="0 0 10 10">
      <path d="M2,2" />
    </svg>

    Not surprising then to find that LineTo is akin to putting pen to paper and drawing from one point to another. Let’s draw the first segment of our heart by drawing a LineTo (L) with coordinates (4,4), represented as L2,2 next in the d attribute:

    <svg viewBox="0 0 10 10">
      <path d="M2,2 L4,4" />
    </svg>

    We’ll add a final line segment as another LineTo L with coordinates (6,2), again appended to the d attribute as L6,2:

    <svg viewBox="0 0 10 10">
      <path d="M2,2 L4,4 L6,2" />
    </svg>
    diagram of line segments drawn on a graph

    If you stop to preview what we’ve accomplished so far, you may be confused as it renders an upside-down triangle; that’s not quite a heart yet, Let’s fix that.

    SVG shapes apply a fill by default, which we can remove with fill="none":

    <svg viewBox="0 0 10 10">
      <path d="M2,2 L4,4 L6,2" fill="none" />
    </svg>

    Rather than filling in the shape, instead, let’s display our line path by adding a stroke, adding color to our heart.

    <svg viewBox="0 0 10 10">
      <path 
        d="M2,2 L4,4 L6,2" 
        fill="none" 
        stroke="rebeccapurple" />
    </svg>

    Next, add some weight to the stroke by increasing the stroke-width:

    <svg viewBox="0 0 10 10">
      <path 
        d="M2,2 L4,4 L6,2" 
        fill="none" 
        stroke="rebeccapurple" 
        stroke-width="4" />
    </svg>

    Finally, apply a stroke-linecap of round (sorry, no time for butt jokes) to round off the start and end points of our line path, giving us that classic symbol of love:

    <svg viewBox="0 0 10 10">
      <path 
        d="M2,2 L4,4 L6,2" 
        fill="none"
        stroke="rebeccapurple"
        stroke-width="4"
        stroke-linecap="round" />
    </svg>
    CodePen Embed Fallback

    Perfection. Now all that’s left to do is send it to that special someone.

    💜


    Handwriting an SVG Heart, With Our Hearts originally published on CSS-Tricks, which is part of the DigitalOcean family. You should get the newsletter.

    Source: Read More 

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleProgetto GRUB 2025: Novità e Miglioramenti
    Next Article Volta – JavaScript Tool Manager

    Related Posts

    News & Updates

    The Alters: Release date, mechanics, and everything else you need to know

    June 2, 2025
    News & Updates

    I’ve fallen hard for Starsand Island, a promising anime-style life sim bringing Ghibli vibes to Xbox and PC later this year

    June 2, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Distributed training and efficient scaling with the Amazon SageMaker Model Parallel and Data Parallel Libraries

    Development

    Man Cures 5-Year Jaw Problem in 60 Seconds Using ChatGPT, Doctors Are Stunned

    Artificial Intelligence

    U.S. Department of Justice Urges Court to Reject Appeal Challenging TikTok Ban

    Development

    Edge AI and It’s Advantages over Traditional AI

    Development

    Highlights

    Linux

    Rilasciata Void Linux Febbraio 2025: Supporto per Apple Silicon e Nuove Funzionalità

    February 3, 2025

    La distribuzione GNU/Linux Void Linux, nota per la sua indipendenza da systemd (un sistema di…

    How Neurodiversity Shines at MongoDB

    April 28, 2025

    5 Best Free and Open Source Terminal-Based Matrix Clients

    January 31, 2025

    Rilasciato Amarok 3.2: Supporto per Qt 5 e Qt 6 ed altre Novità

    December 30, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.