Weird Tech fancy Words
I need to know what is...
HTML
HTML (index.html): The skeleton of ≈ 90% of every site. Is all about tags and attributes.
Usage + Examples
<a title="User's Website" href="https://user-maldito.neocities.org" alt="User's Website">Visit User's Website!</a> <br> <span>It's so cool and retro and hacker and handsome... I love it</span>
Where "<", a keyword and ">" represent the beginning of the tag and "<", "/", a keyword and ">" the end of it. Example:
<div id="container"> (level 0) <a>This is an anchor tag. I will let you visit another link. Just click me</a> (level 1) <p>I am a paragraph tag. You can write on me <strong> Bold the text with me!</strong> (level 2)</p> (level 1) <p hidden>I am the same paragraph tag, but I have an special attribute to hide myself</p>(level 1) </div>(level 0)
The attributes give them "special effects". Some of them are unique for every tag.
> Theoretical example: the "hidden" attribute of the "p" tag has a hidden effect. The attribute "title" in almost every tag has the effect of, on hover, display the text given (like I have in all my website LoL)
> Practical Example:
<span title="Yey! You hover me!">Hover me to get more info</span>> Output: Hover me to get more info
CSS
CSS (style.css): CSS is used to set the squeleton a bit of style. Putting it a suit and tie to the HTML.
Usage
> There are 2 method to add the style:
-
Inside HTML: using the tag <style></style> and write it inside.
Example:
<body> <style> body{ color: white; background-color: black; } </style> </body>
-
Outside HTML: using the tag <link></link> with the attributes ⇒ rel="stylesheet" & href="project/css/style.css" inside the head tag
Example:
<html> <head> <link rel="stylesheet" href="folder/css/style.css"> </head> <body> . . . </body> </html>
And the style.css looks like:
body{ color: white; background-color: black; } p{ cursor: crosshair; text-align: center; }
User's Recommendation
>Separate the style for a better understanding and scalability (even with small projects) & Nesting CSS:
<style> body{ color: white; background-color: black; p{ color: red; } .important{ background-color: lightblue; >a{ margin: 0 10px; &:hover{ text-decoraton: none; } } } } </style>
Syntaxis
HTML tags + CSS Selectors* + { + css attributes + }
Main CSS Selectors* ⇒ Examples:
-
[" "] ⟹ (body p) = Search any P tag inside the tag BODY - any level -
-
[">"] ⟹ (div>p) = Search the direct P tag inside the tag DIV - only the first level -
-
["+"] ⟹ (li+a) = Search the A tag being the upper tag LI - only this (consecutive) combination -
-
["[attribute]"] ⟹ (span[title]) = Search the SPAN tag with the "attribute" TITLE - all span with title will be selected -
-
["*"] ⟹ (div *) = Search ALL TAGS in the DIV tag - all tags in the first level, combination of " " and ">" -
JS
JS (script.js): Is a Programming Language (HTML and CSS is NOT) and is used as well as Client as Server.
Usage
- Manage and Validate info before sending it to the server (as a protection method)
- Handle Events ("This website says: ", "If you click here, something happens", ...)
- Present more Info and Data (HTML and CSS throgh JS, modify the behavior of the page, play sounds and videos, )
- Search info (fetch function [XHR is outdated])
- And all of it asynchronous
Syntaxis
Variables
It has 3 type of variables: let, var and const.
Basic example:
const firstNumber = 5; //Can't change let secondNumber = 3; secondNumber = 5; //Changed the data stored var result = firstNumber + secondNumber; console.log(result); //Expected output: 13
Functions
Function: piece of encapsulated code
Defined with function, FunctionName, "()" followed by "{}". The "return" keyword (inside, in the end of {}) gives you back the value (made to be stored in a variable)
Advanced Example:
function FastCalc(firstNumber, secondNumber){ //This variable does not exist outside the brackets let resultCalc = firstNumber + secondNumber; return resultCalc; } var result = FastCalc(2, 7);
Or like a variable:
const fastCalc = (firstNumber, secondNumber) => { return firstNumber + secondNumber; } var result = fastCalc(2, 7);
Conditionals
Conditionals: "If something happens, I will do this". There is 2 type of conditional if else and switch
let number = 28; let isNumber = true; //Only enter if the statement is true if (isNumber) { alert("Is a number!"); } else{ alert("Is not a number :c"); } //The question mark "!" announce that is the oposite if (!isNumber) { //If is NOT a number... //Only go here if the statement is NOT true or if it's false, it's the same alert("Is a number!"); } // && = and -> || = or //If is a number and is 18 or higher... if ((isNumber) && (number >= 18)) { alert("The number inserted is correct. You can go inside...") } if ((isNumber) || (number != 0)){ alert("You can see this text if "isNumber" is true OR the variable number is NOT 0); }
//Switch case with numbers let number = 2; //Number goes 1 to 3 switch (number) { case 1: BadScore(); break; case 2: MediumScore(); break; case 3: PerfectScore(); break; default: console.log("The default "gateway" happens when none of the other cases is true"); break; } //Switch case with boolean values (true or false) let number = 2; //Number goes 1 to 3 switch (true) { case (number < 0): BadScore(); break; case (number == 0): MediumScore(); break; case (number > 0): PerfectScore(); break; default: console.log("Innecesary default case because you have cover the 3 scenarios: when the number is LESS THAN 0, when IS 0 and when is MORE THAN 0"); break; }
Loops
There are 3 types of logic loops: while, do while and for
//dowhile function DoWhileLoop(){ let index = 1; do{ //The first iteration is free //Repeat the code while the index is less than 3 console.log(index); index++;//IMPORTANT to iterate correctly //when the index is more than 4, the loop will break } while (index < 4); } //while function WhileLoop(){ let startIndex = 0; let endIndex = 5; const number = 3; var isMyNumber = false; while (startIndex <= endIndex){ //if 0 is less or equal than 5? yes -> execute the code inside if (startIndex >= number){ //when the index is EQUAL or MORE than 13, isNumber will be true isMyNumber = true; } console.log(startIndex); startIndex++;//IMPORTANT to iterate correctly } console.log("My number was found?: " + isMyNumber); } //for loop function CountingLoop(){ console.log("Counting 0 to 10"); for (let index = 0; index < 11; index++){//Auto-Increment (index++) console.log(index); } } What will be the output? (PC Only) Copy the function code > press f12 > Go to Console > Paste the code > Call the function --> CountingLoop() Try differents number and see the output!
User's Tips and Tricks
Significant Variable Names (please!!!)
//Do you understand this code? let a = 100; let b = 14; let c = a-b; console.log(c); //And this code? let maxHealth = 100; let damage = 14; let currentHealth = maxHealth - damage; console.log(currentHealth); //The main difference is the variable names! for (let i = 0; i < 4; i++) { for (let j = 0; j < 4; j++) { //Code Here } //Code Here } for (let firstIndex = 0; firstIndex < 4; firstIndex++) { for (let secondIndex = 0; secondIndex < 4; secondIndex++) { //Code Here } //Code Here } //The variable names can tell you with 2-3 words //the CONTEXT of the code with no knowledge
Implement it to the Page
Like the CSS method, JS have 2 methods:
Inside the HTML
//index.html: <body> . . . . <p onclick="ClickEvent()"> Click Me! </p> <script> function ClickEvent(){ alert("I was clicked!"); } </script> </body>
Outside the HTML
//index.html: <body> . . . . <p onclick="ClickEvent()"> Click Me! </p> <script src="/folder/js/script.js"> </script> </body> //script.js: function ClickEvent(){ alert("I was clicked!"); }
I will always recommend using CSS and JS using the "outside method" (linking the document in the HTML and modifying the content outside). Why? My reason is: Scalability and Modularization, Performance and Clean Workplace
Transform the for into while -> and the while into the do while
//Transform the For loop To a While Loop 1. For Loop for (let index = 0; index < 11; index++){ console.log(index); } 2. let index = 0; this go up like this: let index = 0; for (index < 11; index++){ console.log(index); } 3. The Auto-Increment Goes Inside (IMPORTANT: always in the bottom part) let index = 0; for (index < 11){ console.log(index); index++; } 4. Change the keyword for to while (and Voilà!) let index = 0; while (index < 11){ console.log(index); index++; } //Transform the While Loop into the Do-While loop 1. While Loop let index = 0; while (index < 11){ console.log(index); index++; } 2. Copy the While part and put it on the bottom like this: let index = 0; { console.log(index); index++; }while (index < 11);//REMEMBER TO PUT ";" AT THE VERY END 3. Put the keyword Do: let index = 0; do{ console.log(index); index++; }while (index < 11);
Words
Bootstrap
Is a CSS Framework that works around classes.
Example on Flex Behavior Here!Masonry
Is a JS Grid Layout used to make responsive and dynamic website (My gallery have Masonry :D) (When you change the zoom and the photos reorder automatically? That's the magic of Masonry)
More Example of Masonry here!Front-End / Back-End / API Explained :D
Imagine the Web as a Restaurant: The Front-End will be the Showcase. The Back-End is the Kitchen. The API is the Waiter/Waitress and the Database could be seen as the Pantry.