I’m a pretty simple AI user: I ask questions, get help with code, and sometimes let an AI build an entire app for me. Even though most AIs work the same way, I still use several of them. In the U.S., my main tools are Copilot, Gemini, and Cursor. If you’re curious about Chinese AIs, here’s a list of the ones I personally use and recommend — and yes, they’re all accessible outside China. There are so many others, but I have used and am mostly familiar with the ones in this list here.





For those who are curious and are wondering what kind of Chinese apps are out there or which may be some popular ones, here is a list

Some music apps
Two of the most popular music apps that have been in China forever. Perhaps these are the oldest:


There are many other Chinese music apps that are big and just as popular such as Kugou Music 酷狗音乐, which is another big one and newer ones such as Muse AI音乐, but the two I had listed above are the most used and perhaps the oldest.
Some apps to watch movies, tv shows, and quick videos




CCTV (中央电视台)
CCTV is China Central Television, the national state‑run broadcaster of the People’s Republic of China. It’s the largest and most influential TV network in the country, operating dozens of channels covering news, documentaries, entertainment, sports, and international programming.
Personally, CCTV is one of my favorites. It’s free, easy to access, and its content is widely available — many of their channels even upload broadcasts to YouTube.
CCTV isn’t an app outside of China; you simply access it through a web browser. Inside China, it’s just regular public television that people watch when they turn on their TVs.
I find a lot of good movies on CCTV‑6, and CCTV‑8 has tons of TV dramas. CCTV‑8 isn’t usually available outside China unless you use a reliable VPN, but you can still find plenty of CCTV‑8 content on YouTube.
If you want to explore it yourself, just open your browser and try one of their official channels.


Some social media apps
Of course, there are the obvious ones — WeChat and Alipay — but I won’t dwell on them here. For people outside of China, especially those who have never lived there, these apps aren’t very useful. Inside China, they’re essential for daily life: communicating with coworkers and family, sending and receiving money, paying bills, and handling almost every part of modern living.
They do have entertainment features like mini‑games, TikTok‑style video feeds, livestreams, and articles, but their full functionality really shines only when you’re physically in China.
From what I’ve seen, opening an account outside China can be a bit difficult. But if you’re up for a challenge — and a little adventure — you can give it a try.
There are so many Chinese social media apps that are really popular so I will only name the few that I am most familiar with.




Douyin (抖音)
抖音 (Dǒuyīn) is the Chinese version of TikTok — in fact, it’s the original app that TikTok was built from.
It is different from the TikTok here is some ways. It has:
Local services integration — food delivery, hotel booking, maps, and shopping inside the app.
E‑commerce features — creators can sell products directly in videos.
Chinese‑only content — dramas, livestreams, news, and influencers specific to China.
Stronger parental controls — mandatory youth mode for minors.
Different algorithm behavior — tuned for Chinese culture and trends.
抖音 is more like TikTok + Instagram + Amazon + Meituan (Chinese Uber Eats, Uber) combined.

Kuaishou (快手)
Kuaishou (快手 / Kuàishǒu) is one of China’s biggest short‑video and livestreaming platforms — often described as Douyin’s (TikTok’s) “grassroots” competitor.”
Kuaishou is a short‑video social media app created in 2011. It focuses heavily on:
It’s known for being authentic, down‑to‑earth, and less polished than Douyin.
It’s extremely popular, especially outside major cities, and has a very different vibe compared to Douyin. Difficult to access outside of China though. They have an international version that I have never used. I am sure it is not as good as the Chinese version though.

Xiaohongshu (小红书 / Xiǎohóngshū)
Xiaohongshu is a lifestyle social media + e‑commerce platform. It is one of China’s most important social media apps — often described as China’s Instagram + Pinterest + TikTok + Yelp all in one. It’s a lifestyle‑sharing platform built around photos, short videos, reviews, and personal recommendations.
It’s extremely popular among young people in China and very accessible to users outside China. I use this daily and I highly recommend it.


Tantan (探探 / Tàntàn)
Tantan is one of China’s most popular dating apps — basically China’s Tinder. It’s built around swiping, matching, chatting, and short video profiles, and it’s widely used in big cities by young adults.


HelloTalk
If you are interested in learning Chinese. This is the best.
is one of the most popular language‑exchange social apps in the world — and in China it’s especially famous because millions of Chinese people use it to talk with foreigners.
It’s basically a social network for learning languages, built around chatting, voice messages, video calls, and cultural exchange.


I’ve been studying Chinese for a long time now — at the time of writing this, about eight years. By normal standards, maybe I’m fluent, but my personal definition of fluency is much stricter: native‑level understanding, knowing every word, and being able to read and write thousands of characters. Because of that, I still study Chinese almost every day. It’s been a fun and interesting journey, and I’ve made a lot of friends along the way. Today, I want to share how that journey began.
Without diving into the long version of the story, I’ll start with the moment everything changed. One day, I stumbled across an opportunity to live in China and teach English. As soon as I knew I was going — about a month or two before the actual move — I started studying Chinese. At first, I didn’t know where to begin. I explored articles online, tried random apps I found in the Microsoft Store, and experimented with anything that looked helpful. Eventually, I settled on an app called HelloChinese, and for a while, I used it exclusively.



In the beginning, I wasn’t very strict with myself. I did one lesson a day — maybe five minutes of studying. My goal wasn’t to rush through the app; I wanted to actually memorize the sentences and words I was learning. Five to ten new words a day was enough to keep me challenged for a while.
Before I came to China, I mostly studied during my bus rides to and from work. When I finally moved to China, I shifted my routine and started studying first thing in the morning, sometimes while still lying in bed. The app helped me a lot during that time, and I wasn’t shy about using the words I learned in real life.
I remember the moment I realized I was making real progress. I had just finished the lesson about giving directions. One night, I was out shooting pool with a friend — another foreigner who didn’t know any Chinese at all. We lived in the same apartment complex, and although neither of us knew the exact address, I at least knew how to get home. We caught a taxi on the street, and I had fun giving the driver directions in Chinese: turn left here, turn right there, go straight, etc.


Eventually I started extending my study times. I started studying for about an hour a day at least and I spent a lot of weekend nights drinking Baijiu (a Chinese wine) and studying and searching for other material to use and study and such.

After I finished the HelloChinese app, I felt a bit disappointed. Even though I had completed every lesson, I didn’t feel fluent at all. At that point, I only knew the basics. Overall, it felt like I still didn’t know anything, so I started experimenting with other methods of studying.
Besides talking with locals in daily life, I also chatted with people online using an app called iTalkie. Hanging out with locals was definitely easier, but I still needed something to study during my private time. That’s when I started using another app called ChineseSkill. It gave me more material to work with and helped fill the gaps I felt after finishing HelloChinese.




Although both apps were good, I found ChineseSkill to be a bit more challenging than HelloChinese. What surprised me most was how every app I tried offered something new and different. No matter which one I used, each had its own strengths, its own teaching style, and its own way of presenting the language. Eventually, I finished this app as well.
One thing I’ve learned over the years is that these apps never really “end.” They’re always updating, adding new lessons, new features, and new ways to practice. Even today, I still explore apps like these. They offer much more than simple lessons — they provide exercises, stories, dialogues, quizzes, and tools that keep the learning process fresh and interesting.
After finishing those apps, I eventually moved on to textbooks. The first one I used was Integrated Chinese. To be honest, I wasn’t very impressed. A lot of the material covered the same basics I had already learned from apps like HelloChinese and ChineseSkill. I can’t remember exactly how many books are in the series — maybe two or three — but I did go through all of them.
Around this time, I was still spending a lot of time with locals, but I also started using an app called HelloTalk. This app quickly became one of my best tools for finding Chinese people to talk with. I still use HelloTalk today. It’s obviously a great app and one of my favorites. I’ve been using it for years now, and I’ve made many friends through it — some of whom I even met in person.

During all of this time — whether for learning Chinese or simply out of general interest — I spent a lot of time watching Chinese movies and TV shows, and listening to Chinese music. I actually like Chinese music a lot. If you live in China, you’ll see they have plenty of apps for streaming, very similar to what we have here: their own versions of Netflix, Spotify, and more.
Watching and listening to Chinese content became a natural part of my daily life. It wasn’t just studying anymore; it was exposure. I heard real conversations, natural pronunciation. CCTV is great for catching authentic free Chinese TV. Perhaps I will make a list of TV and music apps in another blog post.
After I finished exploring Integrated Chinese, I moved on to another textbook called Developmental Chinese (《汉语发展》 Hànyǔ Fāzhǎn). This series is meant for learners who have reached an intermediate level. The characters in this book are not basic at all, and there’s no pinyin or reading assistance. If you want to study a book like this, you need to already feel comfortable reading basic characters on your own.
It was a very challenging textbook. I studied the first book in the series and eventually started the second one, but I dropped out halfway through. Recently, I decided to return to the first book to review and rebuild my foundation. So as I write this blog, Developmental Chinese is actually one of the textbooks I’m studying again.
Currently, I also use an app called Super Chinese. It is, without a doubt, better than HelloChinese and ChineseSkill. It’s a newer app that uses AI, and it feels modern, intuitive, and far more advanced than the older apps I used. In my opinion, it’s the best Chinese‑learning app available right now.

So that has been my journey. These days — in this era of “maxing,” looksmaxxing, skillmaxxing, and everything else — I guess you could say I’m China‑maxxing. I live a partially Chinese lifestyle: I go to Chinese restaurants all the time, I’m always watching Chinese movies and dramas, I listen to Chinese music, and I even cook authentic Chinese food at home.
Cooking has become one of my favorite study methods. I follow Chinese recipes, listen to the instructions, and read them in Chinese. For the dishes I’ve practiced, I’ve learned to understand the cooking steps clearly. I especially enjoy making Chinese medicinal meals — that has become my favorite part of cooking.
Even now, I still have a long way to go before reaching my language goals. But it has been a fun, meaningful, and life‑changing journey so far.
Thank you for reading.
display: flex — establishes the flex container (readies the flex box for future flexbox settings)
flex-direction
flex direction determines are flex items are placed in the container. flex-direction is used when you want to determine rather something is aligned vertically or horizontally
flex-direction: row — this is the default setting. a lot of times there is no need to set this. It aligns the elements horizontally along the x-axis
ALL flex-direction settings
row is the default setting(—> horizontal to the right)
row-reverse (<— to the left horizontal)
column ( aims to the south)
column-reverse( aims to the north)
flex basis–this has a higher specificity rating than width. It is like the new version of setting the width. When flex basis is used, the normal width setting is ignored. But it doesn’t ignore min-width and max-width values. When the focus is vertical instead of horizontal, it will deal with height.
justify-content–this is used to define the alignment of flex items along the main axis of a flex container. The main axis can be either a row (horizontal) or a column(vertical), depending on the value of the flex-direction property.
All justify-content settings
flex-start–aligns items to the start of the container,
which is the left side in a row and the top in a column.
flex-end–aligns items to the end of the container, which is the right side
in a row and the bottom in a column.
center–just centers items along the main axis.
space-between–distributes items evenly, with the first item at
the start and the last item at the end of the container.
space-around–distributes items evenly, with equal space
around each item. The first and last items have half the space of the
other items.
space-evenly–distributes items evenly, with equal space between each item and the container edges.
stretch–stretches all items to fill the container along the main axis. This is the default if no other value is specified.
align-items–used to align flex items along the cross axis of a flex container. The cross axis is perpendicular to the main axis, which is determined by the flex-direction property.
Align-Items Flex Direction Properties
flex-start–aligns items to the start of the cross axis. In a row(horizontal) flex container; this aligns items to the top. In a column(vertical) flex container, this aligns items to the left.
flex-end–aligns items to the end of the cross axis. In a row flex container, this aligns items to the bottom. In a column flex container, this aligns items to the right.
center–centers items along the cross axis.
baseline–aligns items based on their baseline. This is useful for aligning text.
stretch–stretches items to fill the container along the cross axis. This is the default value if no other value is specified.
align-self–used to align a specific flex item along the cross axis of its flex container, independently of the alignment defined by the align-items property on the flex container.
All Align-Self Properties
auto–will inherit the align items value from its parent flex container. If no align-items value is set on the container, it will default to stretch.
flex-start–aligns items to the start of the cross axis. In a row(horizontal) flex container; this aligns items to the top. In a column(vertical) flex container, this aligns items to the left.
flex-end–aligns items to the end of the cross axis. In a row flex container, this aligns items to the bottom. In a column flex container, this aligns items to the right.
center–centers items along the cross axis.
baseline–aligns items based on their baseline. This is useful for aligning text.
stretch–stretches items to fill the container along the cross axis. This is the default value if no other value is specified.
align-content–is used to distribute space between and around flex lines when there is extra space along the cross-axis, which is the axis perpendicular to the main axis. This property is similar to align-items, but whereas align-items affects individual flex items on the cross-axis, align-content affects the space between and around multiple flex lines.
Align-Content Properties
flex-wrap is set to wrap or wrap-reverse).The align-content property can take several values:
flex-start: Aligns the flex lines to the start of the flex container’s cross-axis.flex-end: Aligns the flex lines to the end of the flex container’s cross-axis.center: Centers the flex lines along the cross-axis.space-between: Distributes the flex lines evenly within the flex container along the cross-axis, such that there is a half-size space at the start and end of the flex container.space-around: Similar to space-between, but the spaces between the flex lines are equal, and there is also a half-size space on either end of the flex container.space-evenly: Distributes the flex lines so that the space between each line and the flex container edges is equal.stretch (default): If the flex lines don’t fill the flex container, this value stretches the lines to fill the remaining space along the cross-axis.flex-grow–specifies how a flex item should grow relative to the rest of the flex items in the flex container when there is extra space available along the main axis
Flex-Grow Properties
Default Value: The default value of flex-grow is 0. This means that the flex item will not grow to take up any available space beyond its initial size.
Equal Distribution: If all flex items have the same flex-grow value (for example, all set to 1), any available space will be distributed equally among them.
Proportional Growth: If one flex item has a flex-grow value higher than the others, it will grow more than the others in proportion to its flex-grow value. For instance, if one item has flex-grow: 2 and another has flex-grow: 1, the first item will grow twice as much as the second one when extra space is available.
Value: The value of flex-grow is a positive number (without any units). This number determines the proportion of available space the flex item should take relative to the other flex items.
Usage: It’s often used along with flex-basis, which specifies the initial size of the flex item before any available space is distributed, and flex-shrink, which controls how the flex item shrinks if there isn’t enough space.
flex-shrink–determines how a flex item should shrink relative to the rest of the flex items in the flex container when there isn’t enough space on the main axis to accommodate all flex items at their default or current size.
Flex-Shrink Properties
Default Value: The default value of flex-shrink is 1, which means that flex items will shrink if necessary to fit into the flex container.
Preventing Shrinking: A value of 0 for flex-shrink indicates that the flex item should not shrink, regardless of the available space in the flex container.
Shrinking Proportion: The flex-shrink value is a positive number without units, which acts as a multiplier for the amount of space the flex item will relinquish when the container is not large enough to hold all flex items at their current size.
Relative Shrinking: If all flex items have the same flex-shrink value, they will shrink equally. However, if the values differ, the item with the higher flex-shrink value will shrink more than others.
Shrink Rate: The actual rate at which a flex item shrinks is also influenced by its flex-basis property. The flex-basis property defines the initial size of the flex item before any shrinking occurs.
Usage: It’s often used in conjunction with flex-grow and flex-basis to control the layout of flex items within a flex container, ensuring that the items fit within the available space.
order–specifies the order in which flex items are laid out in their flex container. By default, flex items are laid out in the order they appear in the HTML source code. However, the order property allows you to change the visual order without having to change the actual order of the elements in the document.
Order Properties
The order property accepts integer values (..., -3, -2, -1, 0, 1, 2, 3, …), where:
A larger value means the element will be ordered later (further to the right or bottom, depending on the flex direction).
A smaller value means the element will be ordered earlier (closer to the left or top).
A value of 0 means the element will use the default order, which is the order in which the elements appear in the source code.
flex-wrap–specifies how flex items should behave when the space in the flex container is insufficient to hold all flex items in a single line. It controls whether the items are forced into a single line or allowed to wrap onto multiple lines, and the direction in which the lines are stacked.
Flex-Wrap Properties
nowrap: This is the default value. Flex items will all try to fit in a single line. If there isn’t enough room, the items will overflow the flex container.
wrap: Flex items will wrap onto multiple lines, from top to bottom, if there isn’t enough room for them on one line.
wrap-reverse: Similar to wrap, but the order of the wrapped lines is reversed. The first line will start from the bottom of the flex container and grow upwards.
Flex-Basis In More Detail
flex-basis is a property that defines the initial main size of a flex item before free space is distributed according to the flex factors. It is one of the three main properties that control the layout of flex items, along with flex-grow and flex-shrink.
flex-grow factor is greater than 0.flex-shrink factor is greater than 0.flex-basis can be set to several different values, including:
20px, 5em, 15%).auto: The browser calculates the size of the flex item based on its content.content: Similar to auto, but it may trigger wrapping if the content is too large.The shorthand flex property allows you to specify flex-grow, flex-shrink, and flex-basis in one declaration. For example:
.flex-item { flex: 1 1 10px; /* This means flex-grow: 1, flex-shrink: 1, flex-basis: 10px */ }
Some CSS Shorthand Properties
Flexbox shorthand properties are a way to simplify the syntax and reduce the amount of code you need to write.
Some good resources for flex-box reference
Today I Designed And Developed A Fully Responsive, CAN‑SPAM Compliant HTML Email Template For A VIP Nightlife & Event Promotion Brand, Built With MJML For Cross‑Email‑Client Compatibility. Integrated The Template Into Mailchimp (Free Tier) And Built An End‑To‑End Automated Lead Capture Workflow Using Google Forms And Zapier.
This Is A Mock Project, By The Way. The Theme Of This Project Is As Follows:
A Chicago Nightlife / Events Company Wants People Who Fill Out A Google Form To Automatically Receive Your St. Patrick’s Party HTML Email As A Confirmation + Event Reminder.You Must Set Up The Email Template In ConvertKit, Then Connect It To Zapier So New Signups Get The Email Instantly.
I Am First Tasked With Completing The MJML Email Of Course.

This Code Then Needs To Be Uploaded To ConvertKit (In Today’s Example) I Used Mailchimp Instead. It Is Now A Reusable Template.


During This Process I Also Tested The Email Using Tools Such As Testi.at And Made Sure The Email Looked Good In Various Platforms And Also On Desktop And Mobile.
In The Next Step. I Set Up A Two Question Google Form:


After This, I Made A Zap In Zapier:

I Then Added Subscribers To The Form And Sent Out The Broadcast. I Had Seen The Email In My Inbox.
To Summarize, The Executed Task Were As Follows:
Responsibilities & Technical Work:
Outcome:
A Production-Ready, Professional Email Marketing System That Reliably Captures Leads And Delivers Branded Event Announcements. Fully Scalable, Maintainable, And Representative Of Real-World Email Development And Marketing Automation Workflows.
Tools Used:
MJML, HTML, CSS, Mailchimp, Google Forms, Zapier, VS Code

I did Frontend Mentor’s ‘Newsletter Sign-Up’ challenge. It’s a single-page form that checks your email and, when it’s valid, flips to a little ‘Thanks for subscribing!’ card. I wrote the layout in HTML, styled it with SCSS (so I could nest and organize the CSS faster), and used a few lines of vanilla JavaScript to stop the page reload, show any errors, and swap the views. It’s a good next-step project once you’re comfortable with the basics but not yet using frameworks. I want to explain how to do it as a tutorial here.
Tutorial: Building a Newsletter Sign-Up Form With a Success Message
This tutorial walks you through creating a newsletter sign-up form that validates the user’s email and shows a success message modal. We’ll cover:
So, to begin, we’ll build this project in three stages:
The HTML has two main parts:
First, create a file called index.html. This will hold the structure of our page. In index.html, type the HTML code that is below.
The HTML below will have two main sections:
.container → the newsletter form.email-modal → the success popup (hidden at first)Inside the form we have:
input type="email") so the browser knows to expect an email.invalidEmail) that we’ll show with JavaScript if the email is invalidHere is the success modal, written at the start of the HTML just after the <body> tag:
<body>
<!-- Success Message (hidden initially) -->
<div class="email-modal">
<div class="email-modal__container--content">
<img src="assets/images/icon-success.svg" alt="success icon">
<h1>Thanks for subscribing!</h1>
<p>A confirmation email has been sent to <span class="user-email">ash@lorecompany.com</span>.</p>
<button class="email-modal__close">Dismiss message</button>
</div>
</div>
Finish The Html And Add The Main Newsletter Form
<!-- Newsletter Form -->
<div class="container">
<div class="container__form--left">
<h1>Stay Updated!</h1>
<p>Join 60,000+ product managers receiving monthly updates on:</p>
<!-- A few list items -->
<ul>
<li><img src="assets/images/icon-list.svg"> Product discovery and building what matters</li>
<li><img src="assets/images/icon-list.svg"> Measuring to ensure updates are a success</li>
<li><img src="assets/images/icon-list.svg"> And much more!</li>
</ul>
<!-- The sign-up form -->
<form>
<div class="form-header">
<p>Email address</p>
<p class="invalidEmail">Valid email required</p>
</div>
<input type="text" class="email-input" placeholder="email@company.com" required>
<button type="submit" class="subscribe-button">Subscribe to monthly newsletter</button>
</form>
</div>
<!-- Right side illustration -->
<div class="container__form--right">
<img src="assets/images/illustration-sign-up-desktop.svg">
</div>
</div>
<script src="assets/js/app.js"></script>
</body>
Great ! We Are Done Writing The Html. You Should See All Of The Html(Including The Success Modal) Unstyled For Now. Here Are Some Key Points To Notice:
.email-modal is hidden by default with CSS (display: none)..invalidEmail is the error message shown only when validation fails.form has an input for the email and a button to submit.Now Let’s Do The Styling With SCSS
We’ll Use Variables, Nesting, And Partial-Like Organization.
Create A File Called Main.scss
Lets Do The Nesting In This File.
Let Us Create The Variables First:
// ----------------------------
// Variables
// ----------------------------
$DarkSlateGrey: hsl(234, 29%, 20%);
$CharcoalGrey: hsl(235, 18%, 26%);
$Grey: hsl(231, 7%, 60%);
$Tomato: hsl(4, 100%, 67%);
$White: hsl(0, 0%, 100%);
And Don’t Forget That We Always Need To Do A Css Reset:
// ----------------------------
// Reset
// ----------------------------
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
Let’s Do Some Universal Styling In The In The Body:
body {
font-family: 'Roboto', sans-serif;
background-color: $CharcoalGrey;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
Now lets style the newsletter form
// ----------------------------
// Container Layout
// ----------------------------
.container {
display: flex;
background: $White;
border-radius: 20px;
overflow: hidden;
width: 800px;
max-width: 95%;
&__form--left {
flex: 1;
padding: 2rem;
h1 {
font-size: 2rem;
margin-bottom: 1rem;
color: $DarkSlateGrey;
}
p {
margin-bottom: 1rem;
color: $DarkSlateGrey;
}
ul {
margin-bottom: 2rem;
li {
display: flex;
align-items: center;
margin-bottom: 0.5rem;
img {
margin-right: 0.5rem;
}
}
}
form {
display: flex;
flex-direction: column;
.form-header {
display: flex;
justify-content: space-between;
align-items: center;
.invalidEmail {
color: $Tomato;
display: none;
font-size: 0.8rem;
}
}
.email-input {
padding: 0.8rem;
border: 1px solid $Grey;
border-radius: 5px;
margin-bottom: 1rem;
&.error {
border-color: $Tomato;
background-color: lighten($Tomato, 40%);
}
}
.subscribe-button {
padding: 0.8rem;
border: none;
border-radius: 5px;
background-color: $DarkSlateGrey;
color: $White;
font-weight: bold;
cursor: pointer;
&:hover {
background-color: $Tomato;
}
}
}
}
&__form--right {
img {
width: 100%;
height: auto;
}
}
}
// ----------------------------
// Success Modal
// ----------------------------
.email-modal {
display:none; //hidden by default
background: $White;
padding: 2rem;
border-radius: 20px;
text-align: center;
max-width: 400px;
img {
width: 50px;
margin-bottom: 1rem;
}
h1 {
margin-bottom: 1rem;
color: $DarkSlateGrey;
}
p {
color: $DarkSlateGrey;
span {
font-weight: bold;
}
}
&__close {
margin-top: 1rem;
padding: 0.8rem;
border: none;
border-radius: 5px;
background-color: $DarkSlateGrey;
color: $White;
font-weight: bold;
cursor: pointer;
&:hover {
background-color: $Tomato;
}
}
}
It Is Time To Make The Form Work !
Let’s Prepare The JavaScript.
Create A File Called App.js
Type This Code To Prepare To Manipulate The DOM:
document.addEventListener('DOMContentLoaded', function() {
// your JS code here
});Code language: JavaScript (javascript)
What It Means
document → refers to the entire HTML document (the web page)..addEventListener('DOMContentLoaded', …) → tells the browser:function() { … } → this is the callback (the code that will run once the event happens).Here’s A Little Bit More About DOMContentLoaded And Why It Is Needed:
Imagine Your Script Tries To Grab Something Like:
const emailInput = document.querySelector('.email-input');
Code language: JavaScript (javascript)
If This Line Runs Before The Browser Has Loaded The HTML, Then .Email-Input Doesn’t Exist Yet → You’d Get Null.
Wrapping Your Code Inside DOMContentLoaded Ensures That All Elements Are Available In The DOM Before Your JS Starts Running.
When Does It Fire?
DOMContentLoaded fires as soon as the HTML is fully parsed (but before images, CSS, etc. finish loading).window.onload, which waits for everything (images, fonts, etc.) to load.In Short It Is Just A Safety Wrapper That Says: “Don’t Run My JavaScript Until The HTML Document Is Ready.”
Let’s Select Some Important Elements From The Html:
document.addEventListener('DOMContentLoaded', function() {
// Select important elements
const form = document.querySelector('form');
const emailInput = document.querySelector('.email-input');
const invalidEmail = document.querySelector('.invalidEmail');
const modal = document.querySelector('.email-modal');
const userEmailSpan = document.querySelector('.user-email');
const closeBtn = document.querySelector('.email-modal__close');
const container = document.querySelector('.container');
});
I Can Explain Each Selection In Detail Here:
<form> element on the page.<input> where the user types their email.So Here Is The Big Picture:
This Whole Block Is Basically Collecting References To Important Elements In Your HTML So JavaScript Can “Talk To” Them Later:
Let’s Write The Email Validator Function Now:
document.addEventListener('DOMContentLoaded', function() {
// Select important elements
const form = document.querySelector('form');
const emailInput = document.querySelector('.email-input');
const invalidEmail = document.querySelector('.invalidEmail');
const modal = document.querySelector('.email-modal');
const userEmailSpan = document.querySelector('.user-email');
const closeBtn = document.querySelector('.email-modal__close');
const container = document.querySelector('.container');
// Function to check if email is valid
function emailValid(email) {
return /\S+@\S+\.\S+/.test(email);
}
});Code language: JavaScript (javascript)
Here Is What Is Happening:
Function EmailValid(Email) → Creates A Function Named EmailValid That Takes One Argument (Email = The Text The User Typed Into The Input Box).
Inside, It Uses A Regular Expression (Regex):
/\S+@\S+\.\S+/
And Then Runs .Test(Email) → Which Checks Whether The Given Email Matches That Regex Pattern.
truefalseWhat Does The Regex /\S+@\S+\.\S+/ Mean?
/ ... / → regex pattern\S+ → one or more non-whitespace characters (so no spaces allowed)@ → must contain an at symbol\S+ → more non-whitespace characters after the @\. → a literal dot (the \ escapes it so it’s treated as a dot, not “any character”)\S+ → one or more non-whitespace characters after the dotSo, In Plain English: “This String Must Have Some Text, Then An @, Then More Text, Then A ., Then More Text — All Without Spaces.”
Now Let’s Write The Code That Is The Glue Between The User’s Action (Submitting The Form) And All The JavaScript Logic We Wrote.
Add The Eventlistener Below To App.js Now.
form.addEventListener('submit', (e) => {
// your code runs here when the form is submitted
});
Code language: PHP (php)
Let Me Explain This Part Of The Code.
We Previously Grabbed The Form With:
const form = document.querySelector('form');
Code language: JavaScript (javascript)
Now We’re Saying: “Hey Form, Whenever Someone Submits You (By Pressing Enter Or Clicking The Submit Button), Run This Function.”
The (E) => { … }
(e) → this is the event object, automatically passed in. It holds info about what happened (like which element triggered the event, if Ctrl was pressed, etc.).e.preventDefault(); inside — which stops the browser from doing its default action (reloading the page when a form submits). Let’s do that now. Add This Code Inside Of The Function, Like So:
/ Handle form submit
form.addEventListener('submit', (e) => {
e.preventDefault(); // Prevent form from submitting; stop page refresh
});Code language: PHP (php)
Now Let’s Write The Heart Of The Form Logic. The Code Below Decides:
Add This Block Of Code To The Function:
if (emailValid(emailInput.value)) {
// Hide error
invalidEmail.style.display = 'none';
// Show modal
modal.style.display = 'block';
container.style.display = 'none';
// Insert user's email into modal
userEmailSpan.textContent = emailInput.value;
} else {
// Show error
invalidEmail.style.display = 'block';
emailInput.style.borderColor = 'hsl(4, 100%, 67%)';
emailInput.style.backgroundColor = '#ffe8e6';
}
Code language: JavaScript (javascript)
Let Me Explain:
if (emailValid(emailInput.value))Code language: CSS (css)
emailInput.value → whatever the user typed in the email box.emailValid(...) → our helper function using regex (/\S+@\S+\.\S+/) to check if it looks like an email.In A Nutshell This Line Of Code Is Saying: “If The User’s Email Looks Valid, Run The Success Case. Otherwise, Run The Error Case.”
Now Let’s Look At The Success Case
invalidEmail.style.display = 'none';
modal.style.display = 'block';
container.style.display = 'none';
Code language: JavaScript (javascript)
.container).email-modal).userEmailSpan.textContent = emailInput.value;
invalidEmail.style.display = 'block';
emailInput.style.borderColor = 'hsl(4, 100%, 67%)';
emailInput.style.backgroundColor = '#ffe8e6';
Code language: JavaScript (javascript)
In Plain English, The Code Above Means:
When The User Clicks Subscribe:
If The Email Looks Valid: Hide The Error, Show The Success Modal, And Display Their Email Inside It. If The Email Is Invalid: Show The Error Message + Style The Input Box Red So The User Knows Where The Problem Is.
Finally, Put This Code Into App.js:
// Handle close modal
closeBtn.addEventListener('click', () => {
modal.style.display = 'none';
container.style.display = 'flex';
emailInput.value = '';
emailInput.style.borderColor = 'hsl(231, 7%, 60%)';
emailInput.style.backgroundColor = 'white';
});
This Block Of Code Is All About Resetting The UI When The User Closes The Success Message Modal. Let Me Break It Done For You.
closeBtn.addEventListener('click', …)Code language: JavaScript (javascript)
closeBtn = the “Dismiss message” button inside the modal.modal.style.display = 'none';
.email-modal) disappears.container.style.display = 'flex';
.container) comes back, so the user can subscribe again (or with a different email).emailInput.value = '';
Code language: JavaScript (javascript)
emailInput.style.borderColor = 'hsl(231, 7%, 60%)';
emailInput.style.backgroundColor = 'white';
Code language: JavaScript (javascript)
So Just To Give A Summary:
When The User Dismisses The Success Message:
Basically, This Button Resets The App Back To Its Starting State So The User Can Try Again If They Want.
That’s It. This Is Our Newsletter Sign-Up Form. All Of The Code Can Be Seen Below:
THE HTML:
<body>
<!-- Success Message (hidden initially) -->
<div class="email-modal">
<div class="email-modal__container--content">
<img src="assets/images/icon-success.svg" alt="success icon">
<h1>Thanks for subscribing!</h1>
<p>A confirmation email has been sent to <span class="user-email">ash@lorecompany.com</span>.</p>
<button class="email-modal__close">Dismiss message</button>
</div>
</div>
<!-- Newsletter Form -->
<div class="container">
<div class="container__form--left">
<h1>Stay Updated!</h1>
<p>Join 60,000+ product managers receiving monthly updates on:</p>
<!-- A few list items -->
<ul>
<li><img src="assets/images/icon-list.svg"> Product discovery and building what matters</li>
<li><img src="assets/images/icon-list.svg"> Measuring to ensure updates are a success</li>
<li><img src="assets/images/icon-list.svg"> And much more!</li>
</ul>
<!-- The sign-up form -->
<form>
<div class="form-header">
<p>Email address</p>
<p class="invalidEmail">Valid email required</p>
</div>
<input type="text" class="email-input" placeholder="email@company.com" required>
<button type="submit" class="subscribe-button">Subscribe to monthly newsletter</button>
</form>
</div>
<!-- Right side illustration -->
<div class="container__form--right">
<img src="assets/images/illustration-sign-up-desktop.svg">
</div>
</div>
<script src="assets/js/app.js"></script>
</body>Code language: HTML, XML (xml)
THE SCSS:
// ----------------------------
// Variables
// ----------------------------
$DarkSlateGrey: hsl(234, 29%, 20%);
$CharcoalGrey: hsl(235, 18%, 26%);
$Grey: hsl(231, 7%, 60%);
$Tomato: hsl(4, 100%, 67%);
$White: hsl(0, 0%, 100%);
// ----------------------------
// Reset
// ----------------------------
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Roboto', sans-serif;
background-color: $CharcoalGrey;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
// ----------------------------
// Container Layout
// ----------------------------
.container {
display: flex;
background: $White;
border-radius: 20px;
overflow: hidden;
width: 800px;
max-width: 95%;
&__form--left {
flex: 1;
padding: 2rem;
h1 {
font-size: 2rem;
margin-bottom: 1rem;
color: $DarkSlateGrey;
}
p {
margin-bottom: 1rem;
color: $DarkSlateGrey;
}
ul {
margin-bottom: 2rem;
li {
display: flex;
align-items: center;
margin-bottom: 0.5rem;
img {
margin-right: 0.5rem;
}
}
}
form {
display: flex;
flex-direction: column;
.form-header {
display: flex;
justify-content: space-between;
align-items: center;
.invalidEmail {
color: $Tomato;
display: none;
font-size: 0.8rem;
}
}
.email-input {
padding: 0.8rem;
border: 1px solid $Grey;
border-radius: 5px;
margin-bottom: 1rem;
&.error {
border-color: $Tomato;
background-color: lighten($Tomato, 40%);
}
}
.subscribe-button {
padding: 0.8rem;
border: none;
border-radius: 5px;
background-color: $DarkSlateGrey;
color: $White;
font-weight: bold;
cursor: pointer;
&:hover {
background-color: $Tomato;
}
}
}
}
&__form--right {
img {
width: 100%;
height: auto;
}
}
}
// ----------------------------
// Success Modal
// ----------------------------
.email-modal {
display:none; //hidden by default
background: $White;
padding: 2rem;
border-radius: 20px;
text-align: center;
max-width: 400px;
img {
width: 50px;
margin-bottom: 1rem;
}
h1 {
margin-bottom: 1rem;
color: $DarkSlateGrey;
}
p {
color: $DarkSlateGrey;
span {
font-weight: bold;
}
}
&__close {
margin-top: 1rem;
padding: 0.8rem;
border: none;
border-radius: 5px;
background-color: $DarkSlateGrey;
color: $White;
font-weight: bold;
cursor: pointer;
&:hover {
background-color: $Tomato;
}
}
}
Code language: PHP (php)
THE JAVASCRIPT:
document.addEventListener('DOMContentLoaded', function() {
// Select important elements
const form = document.querySelector('form');
const emailInput = document.querySelector('.email-input');
const invalidEmail = document.querySelector('.invalidEmail');
const modal = document.querySelector('.email-modal');
const userEmailSpan = document.querySelector('.user-email');
const closeBtn = document.querySelector('.email-modal__close');
const container = document.querySelector('.container');
// Function to check if email is valid
function emailValid(email) {
return /\S+@\S+\.\S+/.test(email);
}
// Handle form submit
form.addEventListener('submit', (e) => {
e.preventDefault(); // Prevent form from submitting; stop page refresh
if (emailValid(emailInput.value)) {
//Hide error
invalidEmail.style.display = 'none';
// Show modal
modal.style.display = 'block';
container.style.display = 'none';
// Insert user's email into modal
userEmailSpan.textContent = emailInput.value;
} else {
// Show error
invalidEmail.style.display = 'block';
emailInput.style.borderColor = 'hsl(4, 100%, 67%)';
emailInput.style.backgroundColor = '#ffe8e6';
}
});
// Handle close modal
closeBtn.addEventListener('click', () => {
modal.style.display = 'none';
container.style.display = 'flex';
emailInput.value = '';
emailInput.style.borderColor = 'hsl(231, 7%, 60%)';
emailInput.style.backgroundColor = 'white';
});
});Code language: JavaScript (javascript)
Lastly. I Forgot To Mention That We Need To Make The Form Responsive. Put The Following Code Into The Bottom Of Main.scss:
/***THE MEDIA QUERIES***/
@media only screen and (max-width: 1440px) {
.container {
display: flex;
margin-top: 1.333rem;
width: 60%;
background-color: white;
border-radius: 30px;
}
.container__form--right {
width: 50%;
}
.container__form--left {
padding: 2rem;
font-weight: 400;
color: var(--CharcoalGrey);
width: 50%;
padding: 2rem;
}
.container__form--left--header {
h1 {
font-size: 3.6rem;
font-weight: 700;
color: var(--DarkSlateGrey);
margin-bottom: 1.5rem;
font-weight: 700;
}
p {
margin-bottom: 1.5rem;
}
}
.container__form--left--list {
margin-bottom: 2rem;
li {
display: flex;
margin-bottom: 1rem;
p {
margin-left: 1rem;
}
}
}
.container__form--left--form {
p {
color: var(--CharcoalGrey);
font-weight: 700;
margin-bottom: 0.5rem;
}
form {
display: flex;
flex-direction: column;
label {
font-weight: 700;
margin-bottom: 0.5rem;
}
input {
border: 1px solid var(--Grey);
border-radius: 5px;
padding: 0.9rem;
margin-bottom: 1.5rem;
width: 100%;
}
button {
border-radius: 5px;
padding: 0.9rem;
background-color: var(--DarkSlateGrey);
font-weight: 700;
color: white;
border: none;
cursor: pointer;
width: 100%;
}
}
}
.container__form--right {
padding: 1rem;
img {
width: 100%;
}
}
}
@media only screen and (max-width: 1416px) {
.container {
display: flex;
margin-top: 1.333rem;
width: 60%;
background-color: white;
border-radius: 30px;
}
.container__form--right {
width: 50%;
}
.container__form--left {
padding: 2rem;
font-weight: 400;
color: var(--CharcoalGrey);
width: 50%;
padding: 2rem;
}
.container__form--left--header {
h1 {
font-size: 2.9rem;
font-weight: 700;
color: var(--DarkSlateGrey);
margin-bottom: 1.5rem;
}
p {
margin-bottom: 1.5rem;
font-size: 0.84rem;
}
}
.container__form--left--list {
margin-bottom: 2rem;
li {
display: flex;
margin-bottom: 1rem;
p {
margin-left: 1rem;
font-size: 0.83rem;
}
}
}
.container__form--left--form {
p {
color: var(--CharcoalGrey);
font-weight: 700;
margin-bottom: 0.5rem;
}
form {
display: flex;
flex-direction: column;
label {
font-weight: 700;
margin-bottom: 0.5rem;
}
input {
border: 1px solid var(--Grey);
border-radius: 5px;
padding: 0.9rem;
margin-bottom: 1.5rem;
width: 100%;
}
button {
border-radius: 5px;
padding: 0.9rem;
background-color: var(--DarkSlateGrey);
font-weight: 700;
color: white;
border: none;
cursor: pointer;
width: 100%;
}
}
}
.container__form--right {
padding: 1rem;
img {
width: 100%;
}
}
}
/******TABLET******/
@media only screen and (max-width: 1023px) {
body {
background-color: white;
display: flex;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 1.333rem;
width: 100%;
background-color: white;
border-radius: 30px;
.logoimg {
width: 100%;
padding: 0;
margin-top: -1.3rem;
display: flex;
}
}
.container__form--right {
width: 100%;
}
.container__form--left {
padding: 2rem;
font-weight: 400;
color: var(--CharcoalGrey);
width: 100%;
padding: 2rem;
}
.container__form--right {
padding: 0;
img {
display: none;
}
}
}
/******MOBILE******/
@media only screen and (max-width: 768px) {
body {
background-color: white;
display: flex;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 1.333rem;
width: 100%;
background-color: white;
border-radius: 30px;
.logoimg {
width: 100%;
padding: 0;
margin-top: -1.3rem;
display: flex;
}
}
.container__form--right {
width: 100%;
}
.container__form--left {
padding: 2rem;
font-weight: 400;
color: var(--CharcoalGrey);
width: 100%;
padding: 2rem;
}
.container__form--right {
padding: 0;
img {
display: none;
}
}
.email-modal__close {
margin-top: 10rem;
}
}Code language: PHP (php)
This Is The Page On Desktop:

This Is The Tablet Version:

And This Is The Mobile Version:

Thank You For Tuning In.