Style your next blog with vanilla HTML. No CSS. ๐Ÿ˜ต

vaibhavkhulbe

Vaibhav Khulbe

Posted on June 12, 2020

Style your next blog with vanilla HTML. No CSS. ๐Ÿ˜ต

For adding style to your websites, we need something called CSS HTML.

...said no one ever.

But what if we make it possible? Of course, our browsers understand the Cascading Style Sheets (CSS) to add styles to the HTML elements. It can't just use HTML to both create elements and style them together.

Let's take an edge case. You need to quickly develop a simple personal blogpost. You would usually seek out for a framework/library or some template to start. But you see, the more heavy thing you add to stuff which can be done with bare-bones can be a bit intimidating both for your implementation and website performance. So, we tend to use simple HTML for the content/structure and CSS for styling.

Dudes at XZ made something with the classless CSS concept by which you only write the required HTML syntax and boom, your styles will be automatically be applied.

Is this some dark magic? Nope. It's a ~4.5kb framework... new.css.


Also, not-just-another CSS framework ๐Ÿ˜Œ

So, what's the deal? Do you need to use this in your project everytime for styling? No no no!

new.css is a classless CSS framework to write modern websites using only HTML.

This is specifically useful for small projects, your portfolio site or your personal blog posts where there's not a heavy need of UI customisation. Also, if you actually hate writing CSS (for whatever reason because ideally you shouldn't เฒ เฒฟ_เฒ ), you will find this utterly easy to style.

new.css focusses and gives the lost importance to the semantic HTML. You just write HTML code throughout and the result will be a nice-looking webpage.

Okay, enough of the intro. I see you're interested in making stuff instead of reading this entire sentence which I deliberately wrote that long.


Let's style a webpage without any styling! ๐Ÿฅท

I feel like a ninja writing the above statement. We'll make this (click the HTML button below to see the entire result):

So, who's ready to fall in love with HTML...again?

Ninja GIF

You the ninja!

Before we get out hands dirty with HTML code, we need to add the new.css stylesheets which are actually like a 'brain' to our blog styling.

Just before you end the <head> tag, add the following lines:



<link rel="stylesheet" href="https://fonts.xz.style/serve/inter.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css">


Enter fullscreen mode Exit fullscreen mode

The first one is the CSS file for the default font used i.e. Inter. The latter one is the actual stylesheet for adding the relevant styles you see.

If you want you get the Terminal theme which I used to make it a little nerdy. This can be done by adding another <link> which points to https://newcss.net/theme/terminal.css. Okay, now we're ready.

-> ๐Ÿฑโ€๐Ÿ’ป Make the header and the blog heading

Blog header

In your favourite editor (or an online one like CodePen), use emmet to generate the <header>.

Next, we have the heading part of our blog. We use the regular <h1> tag for the heading and the <p> tag for the subheading. All the other tags can be used wherever you like to. So, I added <a> to use the hyperlink which goes to my About.me page.

To add any spacing (which we refer to as margin or padding space in CSS), just add the line break tag <br>.

Code till now:



<header>Welcome to a webpage written entirely in Vanilla <strike>JS</strike> HTML.</header>

<!-- Heading -->
<h1>THE ROCKET BLOG FROM THE FUTURE ๐Ÿš€</h1>
<p>My thoughts and ideas on rockets and the science behind them. <a href="https://about.me/vaibhav_khulbe" target="_blank">Learn more</a>.</p>
<br>


Enter fullscreen mode Exit fullscreen mode

-> ๐Ÿฑโ€๐Ÿ’ป Make the actual article card

Article card

It all comes down to your creativity and how much you know different elements of HTML to make something like this. By no means, this is a perfect card layout. We need to remember that we're only using the HTML code here to create this so we have zero control on CSS.

Let's break down the not-so-complex card. First, we have the image for the article, a tag, the article title, description and at last a button which should open up the full article.

We add the following code to make this:



<img src="https://images.pexels.com/photos/796206/pexels-photo-796206.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="Space shuttle"/>
<kbd>FEATURED</kbd>
<h4><a href="#">Lorem ipsum dolor sit, amet consectetur adipisicing elit</a></h4>
<p>Optio, beatae! Aut quis id voluptate ullam repellendus. Et sit, ipsa, non consequuntur magnam quaerat temporibus at officiis ab, expedita molestiae liber...</p>
<a href="#"><button><b>READ MORE</b></button></a>


Enter fullscreen mode Exit fullscreen mode

I've used an image from Pexels, an excellent resource for stock photos which we can use for free. To add the tag, I've used the <kbd> tag which stands for The Keyboard Input element. It's typically used to represent a keyboard key like shift.

Notice we have an anchor <a> tag inside the <h4> so that the article title is clickable and can be redirected to a new location. For the demo, it's just #. Same goes for the <button>.

Our first article card should be up and running! ๐Ÿ•บ

-> ๐Ÿฑโ€๐Ÿ’ป Add the card break elements

Card break elements

The two elements are the ones having the red border around them.

The first one is the Details disclosure element represented by <details>. This is very useful when you have to hide the information initially and only by clicking the <summary> element, you can see the entire info. You can put any other HTML element alongside the <summary>. For fun, I used a GIF :')



<details>
    <summary>What was the secret behind this mission?</summary>
    <img src="https://media.giphy.com/media/NdKVEei95yvIY/giphy.gif" alt="Secret GIF">
    <p>Okay, go watch The Office.</p>
</details>


Enter fullscreen mode Exit fullscreen mode

The next one is the regular quote element represented by <blockquote>.



<blockquote>
  โ€œThe Earth is the cradle of humanity, but mankind cannot stay in the cradle forever.โ€ <i> - Konstantin Tsiolkovsky</i>
</blockquote>


Enter fullscreen mode Exit fullscreen mode

This simply contains a sentence from a source. Notice the use of <i> to format the name in italics.

It's done! So, how does it feel to write no CSS? ๐Ÿ˜œ


Where to next? ๐Ÿค”

If you ask me, this can be used to make quick and easy webpages. But I won't use this much for my personal or professional projects simply because first, I LOVE CSS, second, I need a lot of customisation in styling. Who doesn't love centring items! ๐Ÿ˜‰

  • Go ahead and if you can then contribute to this awesome framework:

GitHub logo xz / new.css

A classless CSS framework to write modern websites using only HTML.

new.css

Discord GitHub stars

new.css

A classless CSS framework to write modern websites using only HTML. It weighs 4.8kb.

All it does is set some sensible defaults and styles your HTML to look reasonable. It's perfect for:

  • A dead-simple blog
  • Collecting your most used links
  • Making a simple "about me" site
  • Rendering markdown-generated HTML

Demo: newcss.net


Table of Contents

  • Usage
  • Themes
    • Theme Library
    • Customizing Themes
  • FAQ
  • Made with new.css
  • Sponsors
  • Support

Usage

HTML

Add this line to the end of your HTML's <head>:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1/new.min.css">
Enter fullscreen mode Exit fullscreen mode

If you'd like the font Inter as well (recommended), add this line as well:

<link rel="stylesheet" href="https://fonts.xz.style/serve/inter.css">
Enter fullscreen mode Exit fullscreen mode

npm

npm i @exampledev/new.css
Enter fullscreen mode Exit fullscreen mode

Yarn

yarn add @exampledev/new.css
Enter fullscreen mode Exit fullscreen mode

Themes

new.css uses a color palette that can be easily customized. These are declared as a CSS variable in the :root attribute.

Theme Library

โ€ฆ

May we suggest cleaning out your fans? Or earplugs. ๐Ÿ˜ญ

Source: https://t.co/qrge5lELZL#DevHumour #Developer #Programming pic.twitter.com/VJrehlTc4t

โ€” Microsoft Developer UK (@msdevUK) June 9, 2020

๐Ÿ“ซ Subscribe to my weekly developer newsletter ๐Ÿ“ซ

PS: From this year, I've decided to write here on DEV Community. Previously, I wrote on Medium. If anyone wants to take a look at my articles, here's my Medium profile.
๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
vaibhavkhulbe
Vaibhav Khulbe

Posted on June 12, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About