HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<body class="bg-gray-100 text-xl">
<div id="app">
</div>
</body>
const { useEffect, useState } = React;
const ProgressBar = () => {
const [scroll, setScroll] = useState(0);
const handleScroll = () => {
const totalScroll = document.documentElement.scrollTop;
const windowHeight =
document.documentElement.scrollHeight -
document.documentElement.clientHeight;
const scrollPercent = totalScroll / windowHeight;
setScroll(scrollPercent);
};
useEffect(() => {
window.addEventListener("scroll", handleScroll);
return () => {
window.removeEventListener("scroll", handleScroll);
};
}, []);
return (
<div className="fixed top-0 left-0 w-full h-1 bg-neutral-200 z-20">
<div
className="absolute top-0 left-0 h-full bg-red-600 origin-left"
style={{ transform: `scaleX(${scroll})`, width: "100%" }}
/>
</div>
);
};
const App = () => {
const [count, setCount] = useState(0);
return (
<>
<ProgressBar />
<main className="h-screen max-w-3xl mx-auto px-8">
<header className="my-16">
<h1 className="text-4xl text-blue-400 font-bold"> The Importance of Embracing Green Energy for a Sustainable Future </h1>
</header>
<div>
<p className="my-4"> In today's world, the need for green energy has become more urgent than ever. As we face the challenges of climate change and dwindling fossil fuel reserves, it is crucial that we prioritize and invest in renewable energy sources. While some may argue against the adoption of green energy, it is essential to understand the numerous benefits it offers for a sustainable future. </p>
<h2 className="text-3xl my-4">1. Environmental Preservation:</h2>
<p className="my-4"> One of the most significant advantages of green energy is its minimal impact on the environment. Unlike traditional fossil fuels, renewable energy sources such as solar, wind, and hydropower do not release harmful greenhouse gases or pollutants into the atmosphere. By reducing our reliance on non-renewable energy, we can mitigate the effects of climate change, protect ecosystems, and safeguard the planet for future generations. </p>
<p className="my-4">Transitioning to green energy also helps combat other environmental issues. For instance, renewable energy production does not contribute to the problem of water scarcity, unlike fossil fuel extraction methods, which often require vast amounts of water. Furthermore, the implementation of green energy technologies can help reduce deforestation by curbing the need for land-intensive energy sources like coal mining. </p>
<h2 className="text-3xl my-4">2. Energy Security and Independence:</h2>
<p className="my-4"> Relying on finite fossil fuel resources exposes us to price volatility and geopolitical tensions. In contrast, green energy offers energy security and independence. By diversifying our energy portfolio with renewable sources, we can reduce our dependence on foreign oil and minimize the risks associated with unstable energy markets. This shift empowers countries to become self-sufficient and resilient in meeting their energy needs. </p>
<p className="my-4"> Moreover, renewable energy sources are abundantly available in many regions worldwide. Sunlight, wind, and water resources are naturally replenished and accessible in various locations, allowing countries to harness their indigenous energy potential. This reduces the reliance on energy imports, promotes energy diversification, and strengthens energy independence. </p>
<h2 className="text-3xl my-4">3. Job Creation and Economic Growth:</h2>
<p className="my-4"> Investing in green energy technologies creates a ripple effect in the economy. The transition to renewable energy sources stimulates job growth in various sectors, such as manufacturing, construction, and research and development. These industries provide sustainable employment opportunities while fostering innovation and economic competitiveness. Skilled workers are needed to install and maintain solar panels, construct wind farms, manufacture electric vehicles, and develop advanced energy storage systems. </p>
<p className="my-4"> Additionally, the establishment of renewable energy infrastructure can attract investments and spur economic growth. Regions that invest in green energy often experience increased economic activity, as companies seek to capitalize on emerging markets and technologies. The renewable energy sector provides a foundation for sustainable economic development, offering long-term stability and reducing dependence on volatile fossil fuel markets. </p>
<h2 className="text-3xl my-4">4. Public Health Benefits:</h2>
<p className="my-4"> Burning fossil fuels for energy production releases harmful pollutants that have detrimental effects on public health. These pollutants contribute to respiratory diseases, heart problems, and premature deaths. Embracing green energy leads to cleaner air and water, reducing the occurrence of respiratory illnesses and improving overall public health. By transitioning to renewables, we prioritize the well-being of communities and create a healthier living environment. </p>
<p className="my-4"> Renewable energy sources produce little to no air pollution during operation, reducing the concentration of harmful particulate matter and toxic emissions. This improvement in air quality can lead to a decrease in respiratory illnesses such as asthma and lung cancer, as well as a reduction in cardiovascular diseases. Moreover, the shift to green energy reduces the contamination of water bodies, safeguarding water resources and protecting aquatic ecosystems. </p>
<h2 className="text-3xl my-4">5. Technological Advancements:</h2>
<p className="my-4"> Investing in green energy drives technological advancements and innovation. As more resources are devoted to research and development in the renewable energy sector, breakthroughs occur, leading to improved efficiency and cost-effectiveness of green technologies. These advancements extend beyond the energy sector and can influence various industries, leading to sustainable solutions in transportation, agriculture, and urban planning. </p>
<p className="my-4"> The pursuit of renewable energy has fostered innovation in energy storage technologies, allowing for the effective integration of intermittent sources such as solar and wind into the power grid. This has led to the development of advanced batteries and other storage solutions, revolutionizing the way energy is managed and reducing reliance on fossil fuel-powered backup systems. </p>
<p className="my-4"> Moreover, the growth of green energy has accelerated the advancement of electric vehicle technology, making electric cars more affordable and accessible. The integration of renewable energy and electric vehicles can lead to a significant reduction in greenhouse gas emissions from the transportation sector, which is a major contributor to climate change. </p>
<h2 className="text-3xl my-4">Conclusion:</h2>
<p className="my-4"> While some may argue against the adoption of green energy, the benefits it offers cannot be ignored. Embracing renewable energy sources is essential for preserving the environment, ensuring energy security, stimulating economic growth, improving public health, and driving technological advancements. As individuals, communities, and nations, it is our responsibility to prioritize sustainable energy practices and actively work towards a future powered by clean, green energy. The transition to green energy not only addresses the urgent challenges of climate change but also creates a more prosperous and sustainable world for generations to come. </p>
</div>
<footer className="text-xs py-16 text-neutral-500">Post example generated with ChatGPT</footer>
</main>
</>
);
};
ReactDOM.render(<App />, document.getElementById("app"));
Also see: Tab Triggers