Short link to this workshop: https://workshops.hackclub.com/cringe_101
Cringe 101 will give you the tools to create the most cringiest website ever. We want you to make something totally different from anything we’ve seen before.
Surprise me, your friends, maybe your mom, I don’t know. Just try not to kill anyone.
Cringe 101 should be done after having some experience with making some nice looking things in HTML + CSS.
But we can’t force you — I’m kinda scared of you to be honest. So, this will workshop will be self-enclosed (kinda, we still urge you to go through the workshop below first).
Probably a good decision. Create a beast of a website by following this workshop:
Get it online using:
Curated by yours truly (follow me on Twitter yo), here are some of my favorites.
This isn’t 100% necessary for the code to run (it will still totally do so), but it tells the webpage some key facts that make it run without any hitches.
<!DOCTYPE html>
<html>
<head>
<link href="main.css" rel="stylesheet">
</head>
<body>
</body>
</html>
<html>
+ <head>
+ <body>
are all called HTML Tags.
Tags are what is used to to organize the content of a web page.
<html>
→ Called the opening tag.</html>
→ Called the closing tag.Almost all HTML tags have both an opening and closing tag.
This organizes the website.
<head>
section in our body section, so we close that before opening our <body>
tag.<!DOCTYPE html>
Placed at the top of your document.
<html>
Encloses the entirety of the rest of the document.
<head>
Encloses the code that you don’t want to show up on the page.
<link>
).<link href="main.css rel="stylesheet">
is linking the CSS file to the HTML.<link>
is another tag and inside of it you have a href
that explain the name of the file.
main.css
>.css
→ All HTML files must end with .html
rel=stylesheet
is telling the program that the type of file is a stylesheet, or CSS file><body>
tag represents the content of an HTML document.
<body>
element in a document.GIFs supports animations — so we can get a video!
They deliver beauties like this:
Insert GIFs just like any other image format!
To add an image, use the image tag: <img src="http://website.com/file-name.png">
img
is the tag name → This is self-closing, meaning there is no a closing tag like </img>
.src
is an attribute that specifies the URL of the image.http://imgur.com/ is a website where you can upload and then get a link to the image!
HTML is used for content.
CSS is used to change the way things look and feel.
Let’s break CSS down into an English sentence:
Here’s the CSS:
For every img
tag on the web page
I want all the style properties inside the curly brackets to apply:
specifically, I want the width
to be 50% of the width of the page.
In the CSS, we use selectors to select tags, img
is the selector in our example.
What if you want to call 1 of your 2 <h1>
tags → Both have the same selector right now.
After keyword (<div, <body, <h1, <head
) of any tag type class=“class-name” to create a class
<body class="class-name"> </body>
For example if we wanted the background of our site to be a GIF of Kanye West we could do this:
HTML:
<body class="who"></body>
CSS:
.who {
background:url("https://media3.giphy.com/media/9RTiWDExHW6aY/200.gif ");
}
This means that for every element with the class of “example”, it will have a background image of Kanye West.
Here is a preview of what that does: https://preview.c9users.io/jevinsidhu/cringe-101/index.html?c9id=livepreview0&c9host=https://ide.c9.io
Below is the code for this site:
<!DOCTYPE html>
<html>
<head>
<link href="main.css" rel="stylesheet">
</head>
<body class="who">
<a href="god.html"></a> <!--When an element with the class "who" is clicked it will lead you to a separate page-->
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<link href="main.css" rel="stylesheet">
</head>
<body class="god">
</body>
</html>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
a {
display: block;
width: 100%;
height: 100%;
}
.who {
background:url("https://media3.giphy.com/media/9RTiWDExHW6aY/200.gif ");
}
.god {
background:url("https://media.giphy.com/media/6rclMe3lUIQNi/giphy.gif ");
}
Some fonts really make people cringe. An example of that would be the esteemed Comic Sans.
Changing your font is easy to do and Google Fonts (https://www.google.com/fonts) makes it even easier. There are hundreds of fonts Google offers to use for free on the site.
The best part about Google Fonts is that it gives you the code you need to put on your site.
Steps to add and change fonts:
<link href="https://fonts.googleapis.com/css?family=Baloo+Tamma|Open+Sans|Roboto" rel="stylesheet">
<head>
.<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family= Open+Sans" rel="stylesheet">
</head>
</html>
Now that we added the font, we can actually change our text to the font we like using CSS!
In the example below, we changed all the text to the desired font by using the property font-family
on the body tag. However, if you want to be really cringy, use different fonts for every different piece of text using more specific tags.
body {
font-family: 'Open Sans';
color:#000;
font-size:10px
font-weight:300;
}
Tip — Along with changing the fonts, change the colors (color
) and thickness (font-weight
) of the different text as well to see your friends cringe even more!
You can revisit that workshop for more extensive overview of them, but here’s a quick recap.
A pseudo-class is an exception to a set of rules you created in CSS.
h1:hover {
color: red;
}
The h1
is the tag from the HTML we are working with. The :hover
is the pseudo - class or exception you have added. In this case by adding :hover
you have created an exception to the old color the h1
tag was in and have stated that whenever the mouse hovers the h1
text, it’s color will be red instead.
An example of :hover
in action can be seen on Udit’s site when you go over the words Twitter, Instagram, Medium and Cipher — http://uditdesai.github.io/me
Hopefully you found that example to be really pretty and an effective use of pseudo - classes, however this CSS trick can also be used to make websites really cringy by making every piece of text change colors when hovering over them.
<audio>
TagAn audio tag is super simple to get ready!
All you need to start annoying your friends, family, dog, etc is:
A pair of <audio>
tags.
<audio> </audio>
.<source>
tag inside of those (it’s self closing!).You can have multiple source files inside a pair of audio tags.
<audio>
<source src="audiofile.mp3" type="mediatype">
</audio>
To upload an audio file to Cloud9
You’ll need to upload your sound file directly to C9 if you can’t find it hosted somewhere like this (https://www.anotherwebsite.com/sound.mp3)
Just follow the either method below to upload your file to C9.
Alternate Method
Setting up the <audio>
tags
Okay! Lets start by making a pair of <audio>
tags.
You have your tags in place but they’ll need a bit of configuring to get working. Like all tags in HTML it can accept extra information called attributes to tweak them to your needs.
Attributes are basically like unique properties of a pair of tags:
<div class="bestdiv"></div>
Anything inside the first <>
that isn’t the element name (div) is called an attribute (id=""
, class=""
, etc.)
As such, <audio>
has its own set of attributes that can be applied to them simply by typing them in between the <>
Here’s a list of the unique attributes that <audio>
tags can accept exclusively:
autoplay:
Tells the browser to automatically play the audio once it’s loaded.controls:
Creates a play bar with a play/pause button, sliding bar, and a volume controlloop:
Loops the audio again once it’s finished.muted:
Mutes the audio output. (doesn’t stop the audio from playing, it just has no volume).preload="":
auto:
load the audio file after the page loads.metadata:
only load the metadata (extra info like author, etc that is stored within the file) when the page loads.none:
doesn’t load the audio file when the page loads.src="" :
src=""
Example of an audio tag set to automatically play, and loop an audio file:
<audio autoplay loop src="hotline-bling.mp3"></audio>
<source>
tagsThe <source>
tag simply serves the same purpose as putting a src=""
attribute above, as in it directs the browser to where the audio file is.
<source>
can be used for all sorts of media files, (sound, video, etc) but for this tutorial we’ll just be using it for audio.
This tag also has its own set of attributes like <audio>
also it’s self-closing. src="[URL]":
type="[media-type]"
;source src="blinghotline.mp3" type="audio/mpeg">
Example of <audio>
and <source>
tags properly configured to play a locally hosted darude.mp3
on loop.
<audio loop autoplay>
<source src="audio/darude.mp3" type="audio/mpeg">
</audio>
Did you do this and still aren’t satisfied with the level of cringe? Maybe instead of regular audio you need ADVANCED AUDIO.
There’s an infinite number of things you can do with JavaScript, but for this workshop we’ll show you a way to make JS trigger a sound when any part of your page is clicked!
You do not need the HTML tags from the tutorial above to get this work. But you will need to know how to specify the location of an audio file. (src=""
)
To get this to work you’ll need:
<script type="text/javascript" src="script.js"></script>
An example of a remote audio source would be something like
"www.yeezy.com/onsight.mp3"
If you already have these, awesome! If not, get those setup before continuing with this section.
To begin, let’s open your JS file!
The single line of code that we’ll need to tell JavaScript to “listen” for an event is:
document.addEventListener("[event]", function() {
[Your code to run]
});
You may or may not understand what this chunk of code means so let’s break it down.
document
simply means the HTML document that the JavaScript file was run/linked in (using your <script>
tags).
.addEventListener
means to add a “listener” to trigger something when a certain event happens
So far pretty simple right? document.addEventListener
just means: Start listening to whenever a certain event happens
Now we need to specify what type of event we want our listener to look out for, to do this we put the name of the event in the [event] section of the code.
document.addEventListener("[event]", function() {});
These events have certain names, but thanks to our friends at w3schools
they’ve given us a nicely arranged list of all the HTML events.
Note: You remove the prefix when you use those names inside of document.addEventListener
So following that rule
document.addEventListener("onclick", function() {});
Would turn into:
document.addEventListener("click", function() {});
Now that we’ve told Listener
what to listen for, we need to tell it to run code when it sees what it’s looking for.
To do that, we use function() {}
function() {}
is basically telling JavaScript to run the lines of code inside of {}
With that known, how do we get JavaScript to play audio?
We create a variable with an audio path inside of the {}
using:
var variableName = new Audio('[AUDIOPATH]');
variableName
can be simply anything you want it to be, try to keep it clear and concise though!
[AUDIOPATH]
is where your audio file is, it can either be a website link to the file or the path on your workspace
The path on your workspace to the file is relative to the HTML file, so if your audio file is in the same folder as your HTML file it would just simply be new Audio("example.mp3")
Now for the final step, which is to finally play your audio!
To tell JavaScript to play the audio file stored in the variable all we need to write is:
variablename.play();
variablename
would be the name you set previously when you wrote var variablename
Don’t forget to close your curly brackets of function() {}
and it should work!
document.addEventListener("click", function() {
var wow = new Audio("wow-.mp3");
wow.play();
})
The example plays wow-.mp3
every time a left click is registered on the page.
<marquee>
TagMicrosoft’s <marquee>
tag scrolls a selection of markup across the screen.
The <marquee>
tag creates a 100% wide div (box) with text sliding across the screen.
There are a large number of attributes for the <marquee>
tag.
You can change the width, the alignment, the scrolling speed, the scrolling delay, and even the scrolling direction (right to left or left to right).
It is a tag, so it encloses other tags:
<marquee><div class="cringe"></div></marquee>
Here’s an example of what you can do!
<marquee direction="up" width="100%" height="250" behavior="alternate" style="border:solid">
<marquee behavior="alternate"><img src="https://media.giphy.com/media/TeBpzQZRaBIC4/giphy.gif" height="300px"></marquee>
</marquee>
(your feedback is anonymous + appreciated 💚)