🎃🦇 HTMLoween🦇🎃 HTML, CSS and JS that'll make you scream! 😱
Tags: html, css, javascript, webdev
Published: 2023-10-31 12:00:12

It's spooky time again! A couple of years ago I made you all recoil in horror with my [Halloween article on HTML, CSS and JS monstrosities](https://dev.to/grahamthedev/its-htmloween-scary-html-js-and-css-2ncj).

Well I am back at it again, and this time the examples are more fiendish than ever!

## Contents
- [HellTML](#helltml)
- [JavaScreams](#javascreams) 
- [spooky CSS!](#spooky-css)
- [Some pumpkin carvings to cheer you up!](#some-pumpkin-carvings-to-cheer-you-up)

---

## HellTML
Oh my eyes, my **eyes**. The screams of horror I let out when I saw these:

### A linkB<em>oo</em>tton
```html
<div tabindex="3">
  <div role="button">
    <a href="#">
      <svg> … </svg>
    </a>  
  </div>
</div>
```

### Image butt...oh noes!
``` html
<img src="/images/edit.webp"
     onclick="edit(userID)" 
     onmouseover="openEditPopover(userID)"
>
<br>
<img src="/images/delete.png" 
     onclick="delete(userID)" 
     onmouseover="openEditPopover(userID)"
>
```

### New line nasties!
Oh dear...I don't know what hurts more, the new lines or the `role="sign-up"` 😔

```html
<div
  role="sign-up"
>
    Sign up today!
</div
>
```

### That is just poor form my old fellow!
```html
<form role="form">
  <h4>Do you like</h4>
  <h2>sea food?</h2>
  <div id="poll-question" role="radiogroup">Whould you like sea food?</div>
  <div name="poll-grouping" role="radiogroup">
    <div role="radiogroup">
      <input type="radio" name="seafood" value="[object Object]" data-value="1">
      <span>Yes</span>

      <input type="radio" name="seafood" value="[object Object]" data-value="2">
      <span>No</span>

      <input type="radio" name="seafood" value="[object Object]" data-value="2">
      <span>Maybe</span>

      <input type="radio" name="seafood" value="[object Object]" data-value="2">
      <span>Can you repeat the question?</span>
    </div>

    <button type="submit"><img src="submit.png"></button>
  </div>
</form>

```

### Now that is using your &lt;head(er)>!
```html
<a href="about">
  <header>About</header>
</a>
<a href="faqs">
  <header>FAQs</header>
</a>
<a href="contact">
  <header>Contact</header>
</a>
```

---

## JavaScreams
Oh JS is already scary enough, but some of these practices make my skin crawl!

### Never forget the new!
It is so difficult to remember that pesky `new` keyword when creating classes, luckily this fixes that! 😱


``` js
function Car(colour) {
	if ( !(this instanceof Car) )
	      return new Car(colour);
	this.colour = colour;
}

Car.prototype.getColour = function() {
	return "Colour: " + this.colour;
}

var aCar = Car("Red");
console.log(aCar.colour());
> "Colour: Red"
```

### Disabled, is disabled, is disabled, right?
```js
let disabledState = false;

function isDisabled(isDisabled){
  return isDisabled == false ? false : true;
}

let disabledVal = isDisabled(disabledState);
console.log(disabledVal);
```

### The *number* of ways I hate this
So, who knew that 0.443.232.232...1 was a valid number?

```js
function isNumeric(str) {
    var validCh = "0123456789.";
    var isNum = true;
    var ch = "";
    for (i = 0; i < str.length && isNum == true; i++) {
        ch = str.charAt(i);
        if (validCh.indexOf(ch) == -1) {
            isNum = false;
        }
    }

    //I had to recycle the code from the previous example, just to make this hurt even more
    return IsNum == true ? true : false; 
}

console.log(isNumeric("0.443.232.232...1")) // true! 😔

```

### A true **booo**lean!
``` js
const handleBoolean = value => {
  switch (value) {
    case "true":
      return true;
    case true:
      return "true";
    case 1:
      return "true";
    case "1":
      return "true";
    case "false":
      return false;
    case false:
      return "false";
    case 0:
      return "false";
    case "0":
      return "false";
    default:
      return null;
  }
}
```

### the big reset is coming! 
```js
function resetform()
{
  var field1 = document.getElementById('firstName');
  field1.value = '';	
  var field2 = document.getElementById('lastName');
  field2.value = '';
  var field3 = document.getElementById('dob');
  field3.value = '';
  var field4 = document.getElementById('addLine1');
  field4.value = '';
  var field5 = document.getElementById('addLine2');
  field5.value = '';
  var field6 = document.getElementById('addLine3');
  field6.value = '';
  var field7 = document.getElementById('county');
  field7.value = '';
  var field8 = document.getElementById('postcode');
  field8.value = '';	
}
```

---

## Spooky CSS
You are still here? Wow you are a brave one. But this CSS is sure to finish you off!

### Site-wide styles!
```css
*{
  font-size: 11px!important;
}

*{
  margin: 5px;
}

*{
  padding: 10px;
}

```

### Make sure to minimise your CSS for performance this Halloween!
```css
.p{
  padding: 20px;
}

.m{
  margin: 10px;
}

.u{
  text-decoration: underline;
}

.r{
  color: red;
}

.rb{
  background-color: red;
}

```

### Var you kidding me?
```css
:root{
  --base: 16px;
  --small: calc(var(--base) * 0.8);
  --large: calc(var(--small) * 1.5);
  --padding1: calc(var(--large) * 0.75) calc(var(--small) * 1.2);
}

.padded{
  padding: var(--padding1);
}
```

---

## Some Pumpkin carvings to cheer you up!
You have endured a lot, once again, brave traveller.

As you have made it this far, here as some pumpkin carvings me and my friends did in the last couple of years to cheer you up!

### Gizmo (Gremlins) and House Stark Sigil
Gizmo was one of my favs! 

I decided to do House Stark (probably 3 years ago now)...possibly the hardest carving I have done to date, everything was so fragile!

![Pumpkins carved to show Gizmo from Gremlins and the Sigil for house Stark from Game of thrones](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ie84r3d6fdrbaj1k1rh7.png)

## Darth Maul
Love Star Wars or hate it...Darth Maul is still so iconic I had to carve him!


![Pumpkin Carving of Darth Maul from Star Wars](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e3wbt5izg6pirbzao21c.png)

---
<p>&nbsp;</p>
<p>&nbsp;</p>
<center><h2>Happy Halloween!</h2></center>
<center>Share your <mark>Halloween pics</mark> in the comments!</center>
<p>&nbsp;</p>
<p>&nbsp;</p>
---