Style your next blog with vanilla HTML. No CSS. 😵
Tags: beginners, html, css, tutorial
Published: 2020-06-12 15:07:41

> 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](https://xz.style/) made something with the [classless CSS](https://css-tricks.com/no-class-css-frameworks/) 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](https://newcss.net/)** 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](https://developer.mozilla.org/en-US/docs/Glossary/Semantics#Semantics_in_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):

{% codepen https://codepen.io/kvaibhav01/pen/PoZZwNL default-tab=html,result %}

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

![Ninja GIF](https://media.giphy.com/media/3dJ09sFeN0IjC/giphy.gif)
<figcaption>You the ninja!</figcaption>

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:

```html
<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">
```
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](https://dev-to-uploads.s3.amazonaws.com/i/rfrpegqyt15tuvbwrib5.jpg)

In your favourite editor (or an online one like [CodePen](https://codepen.io/kvaibhav01/pen/PoZZwNL)), use [emmet](https://emmet.io/) 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](http://about.me/) page.

To add any spacing (which we refer to as [`margin`](https://developer.mozilla.org/en-US/docs/Web/CSS/margin) or [`padding`](https://developer.mozilla.org/en-US/docs/Web/CSS/padding) space in CSS), just add the line break tag `<br>`.

_Code till now:_

```html
<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>
```


#### -> 🐱‍💻 Make the actual article card

![Article card](https://dev-to-uploads.s3.amazonaws.com/i/egzibxw8uh05mmpzhsxs.jpg)

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:

```html
<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>
```
I've used an image from [Pexels](http://pexels.com/), 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](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd). It's typically used to represent a keyboard key like <kbd>shift</kbd>.

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](https://dev-to-uploads.s3.amazonaws.com/i/hk0jluam8uwua7ta1ur5.jpg)
<figcaption>The two elements are the ones having the red border around them.</figcaption>

The first one is the [Details disclosure element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details) represented by `<details>`. This is very useful when you have to hide the information initially and only by clicking the [`<summary>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary) element, you can see the entire info. You can put any other HTML element alongside the `<summary>`. For fun, I used a GIF :')

```html
<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>
```

The next one is the regular quote element represented by [`<blockquote>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote). 

```html
<blockquote>
  “The Earth is the cradle of humanity, but mankind cannot stay in the cradle forever.” <i> - Konstantin Tsiolkovsky</i>
</blockquote>
```

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 xz/new.css %}

- Make your own [custom theme](https://github.com/xz/new.css#Customizing) which matches the brand guide.

- If you're stuck somewhere, then join their [Discord server](https://discord.gg/hhuuC4w)!

- I made another Pen from new.css. [Take a look 👀](https://codepen.io/kvaibhav01/pen/gOPaWWg).

---

<blockquote class="twitter-tweet" data-partner="tweetdeck"><p lang="en" dir="ltr">May we suggest cleaning out your fans? Or earplugs. 😭<br><br>Source: <a href="https://t.co/qrge5lELZL">https://t.co/qrge5lELZL</a><a href="https://twitter.com/hashtag/DevHumour?src=hash&amp;ref_src=twsrc%5Etfw">#DevHumour</a> <a href="https://twitter.com/hashtag/Developer?src=hash&amp;ref_src=twsrc%5Etfw">#Developer</a> <a href="https://twitter.com/hashtag/Programming?src=hash&amp;ref_src=twsrc%5Etfw">#Programming</a> <a href="https://t.co/VJrehlTc4t">pic.twitter.com/VJrehlTc4t</a></p>&mdash; Microsoft Developer UK (@msdevUK) <a href="https://twitter.com/msdevUK/status/1270253045545406464?ref_src=twsrc%5Etfw">June 9, 2020</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

---

#### [📫 Subscribe to my weekly developer newsletter 📫](https://mailchi.mp/f59beeac6b9b/devupdates)

##### 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](https://medium.com/@vaibhavkhulbe)'s my Medium profile.