By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: Create A Lightning Text Effect Using HTML And CSS Using This Simple Code | HackerNoon
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > Computing > Create A Lightning Text Effect Using HTML And CSS Using This Simple Code | HackerNoon
Computing

Create A Lightning Text Effect Using HTML And CSS Using This Simple Code | HackerNoon

News Room
Last updated: 2025/03/14 at 10:56 PM
News Room Published 14 March 2025
Share
SHARE

I wanted to recreate the following logo image using only HTML and CSS. For me it was important that the setup supports different font sizes and text content so that I can easily change the logo text and size without any code changes.

Piranhas Logo with Lightning Effect — © PiranhasPiranhas Logo with Lightning Effect — © Piranhas

Solution

1. Setup An HTML Container With Child Elements

<a href="/" class="logo__link">
    <span class="logo__name-pseudo">Piranhas</span>
    <span class="logo__name-top">Piranhas</span>
    <span class="logo__name-bottom">Piranhas</span>
</a>

My idea was to create 2 child elements containing the same text. I would clip one element to the upper half (.logo__name-top) and the other element to the lower part (.logo__name-bottom). Finally, I will displace the upper part to the left. That’s it.

2. Add CSS Properties To HTML Container

.logo__link {
    position: relative;
    color: #ffff00;
    font-family: Outfit, Helvetica, sans-serif;
    font-style: italic;
    font-size: 5rem;
    font-weight: 900;
    text-decoration: none;
}
  • The position property is needed to allow absolute positioning of the child elements.
  • The other CSS properties are just used for styling.

Piranhas Logo: CSS Styling — © PiranhasPiranhas Logo: CSS Styling — © Piranhas

3. Add CSS Properties To HTML Child Elements

.logo__name-top {
    position: absolute;
    top: 0;
    right: 0.05em;
    clip-path: inset(0% 0% 40% 0%);
}
  • The position property is needed to apply absolute positioning to the .logo__name-top element.
  • The right property is used to displace the text to the right.
  • The clip-path property is used to clip the text to the upper 40% and hide the rest.
.logo__name-bottom {
    position: absolute;
    top: 0;
    right: 0;
    clip-path: inset(60% 0% 0% 0%);
}
  • The position property is needed to apply absolute positioning to the .logo__name-top element.
  • This elements stays where is is and is not displaced.
  • The clip-path property is used to clip the text to the lower 60% and hide the rest.

Piranhas Logo: Offsetting The Clipped Area — © Piranhas.Piranhas Logo: Offsetting The Clipped Area — © Piranhas.

As you can see, there are still some remaining issues.

Styling Issues

1. Avoid Clipped Areas For Italic Font Style

I needed to extend the clipping area to the right by adding -5% to the clip-path. Otherwise, some part of the text gets clipped away when using italic font style.

.logo__name-top {
    position: absolute;
    top: 0;
    right: 0.05em;
    clip-path: inset(0% -5% 40% 0%);
}
.logo__name-bottom {
    position: absolute;
    top: 0;
    right: 0;
    clip-path: inset(60% -5% 0% 0%);
}

Piranhas Logo: Avoid Clipped Areas For Italic Font Style — © Piranhas.Piranhas Logo: Avoid Clipped Areas For Italic Font Style — © Piranhas.

2. Parent Element Does Not Use Any Space

Since the child elements are using absolute positioning, they are out of the flow. Therefore, the parent element .logo__linkdoes not take any space and makes positioning the element difficult. You can manually position the parent element but when you change the logo text or size, you would need to manually update the positon of the parent element which is not sustainable.

Therefore, I added a “pseudo” child element in HTML with class .logo__name-pseudo containing the same text in the same style and size which is hidden just to reserve space for the clipped elements. Now the element reains in the flow.

.logo__name-pseudo {
    visibility: hidden;
}

3. Remove Thin Line Between Displaced Elements

There remains a thin line between the 2 elements and I couldn’t figure out the reason. Eventually, it is a rendering issue. It depends also on the logo size. Sometimes it appears and sometimes not. I decided to extend the upper clip area and clip away just 39% instead of 40% of the bottom part. Therefore, the logos slightly overlap and the line is removed. If you have a better solution, let me know in the comments.

.logo__name-top {
    position: absolute;
    top: 0;
    right: 0.05em;
    clip-path: inset(0% -5% 39% 0%);
}

Piranhas Logo: Removing Thin Line Between Displaced Elements — © Piranhas.Piranhas Logo: Removing Thin Line Between Displaced Elements — © Piranhas.Here is the final code on CodePen. Feel free to use.


Originally published on March 13th, 2025 on Philip’s Notes.

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article Should You Replace Your TP-Link Router? We Asked 4 Cybersecurity Experts to Weigh In
Next Article Samsung soundbar owners report major problems after latest firmware update
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

Stellantis’ Chinese partner set to build first European factory in Italy · TechNode
Computing
11 iOS 18 features you’re missing if you haven’t updated your iPhone yet
News
Freshippo achieves four months of profitability after major restructuring: report · TechNode
Computing
US probing impacts of imported jets, aircrafts on national security
News

You Might also Like

Computing

Stellantis’ Chinese partner set to build first European factory in Italy · TechNode

1 Min Read
Computing

Freshippo achieves four months of profitability after major restructuring: report · TechNode

3 Min Read
Computing

Huawei secures self-driving tech contract for BYD’s premium brand: report · TechNode

1 Min Read
Computing

Final trailer for Black Myth: Wukong reveals 72 Transformations and Four Heavenly Kings · TechNode

1 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?