HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URL's added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Recreating Google Homepage</title>
<link rel="stylesheet" href="assessmentSol.css" />
</head>
<body>
<div class="container">
<div class="logo">
<img
class="google-logo"
src="https://cdn.vox-cdn.com/thumbor/p01ezbiuDHgRFQ-htBCd7QxaYxo=/0x105:2012x1237/1600x900/cdn.vox-cdn.com/uploads/chorus_image/image/47070706/google2.0.0.jpg"
/>
</div>
<div class="searchform">
<input style="search" />
</div>
<div class="buttons">
<button>Google Search</button>
<button>I'm Feeling Lucky</button>
<p>Google offered in: <a href="#">Malay</a></p>
</div>
</div>
</body>
</html>
.container {
text-align: center;
width: 100%;
height: auto;
padding-top: 130px;
/* center it */
margin: 0 auto;
}
.logo {
margin-top: 200px;
/* border: 1px solid red; */
}
input {
width: 400px;
height: 30px;
margin-bottom: 15px;
}
a {
text-decoration: none;
}
p {
font-family: arial;
font-size: 9pt;
}
.google-logo {
width: 300px;
}
.buttons {
margin-bottom: 60px;
}
button {
background-color: #f2f2f2;
border: none;
padding: 10px;
margin: 10px;
color: lightslategray;
font-weight: bold;
font-family: arial;
border-radius: 2px;
}
a:hover {
text-decoration: underline;
}
button:hover {
color: black;
border: 1px solid lightgray;
}
// MCQ
// A
// B
// D
// A,B,C
// C
// A,B,C
// A
// A
// C
// B
// Reverse A String Using Loops.
// reverse('abcde') == 'edcba'
// reverse('hello') == 'olleh'
// reverse('Greetings from The Hacker Collective') == 'evitcelloC rekcaH ehT morf sgniteerG'
// function reverse(str){
// let reversed = "";
// for (let i = str.length-1; i >= 0; i--){
// reversed += str[i];
// }
// console.log(reversed);
// }
// Same Back And Forth - Is a string the same backwards and forwards? Return true if it is, false if it is not.
// sameBackAndForth("abba") === true
// sameBackAndForth("abcdefg") === false
ass;
// function sameBackAndForth(str){
// var strRev = str.split("").reverse().join("");
// if (str === strRev){
// console.log(true);
// } else{
// console.log(false);
// }
// }
// Given an integer, return an integer that is the reverse ordering of numbers.
// reverseInt(15) === 51
// reverseInt(981) === 189
// reverseInt(500) === 5
// reverseInt(-15) === -51
// reverseInt(-90) === -9
// function reverseInt(n) {
// const reversed = n
// .toString()
// .split('')
// .reverse()
// .join('');
// return parseInt(reversed) * Math.sign(n);
// }
// SumArr - Find the sum of all items in an array, using loops.
// sumArr([1,2,3,4,5]) == 15
// sumArr([1000,2000,44,55,22]) == 3121
// sumArr([123,456,789]) == 1368
function sumArr(arr) {
let count = 0;
for (let i = 0; i < arr.length; i++) {
count = count + arr[i];
}
return count;
}
// Angry Grandma - You will write a function that takes in a String. The function should return a new sentence where every word is yelled. A yelled word is when each word is all uppercase followed by 2 exclamation marks (!!)
// deafGrandma("I have a bad feeling about this") == "I!! HAVE!! A!! BAD!! FEELING!! ABOUT!! THIS!!"
function deafGrandma(str) {
let split = str.toUpperCase().split(' ').join('!! ');
return (split += '!!!!');
}
// What Is Missing - Find the missing letter in the passed letter range and return it. If all letters are present in the range, return undefined.
// whatIsMissing("abcdefghijklmnopqrstuvwxyz") == undefined
// whatIsMissing("bcdf") == 'e'
// whatIsMissing("abcdefghjklmno") == 'i'
function whatIsMissing(str) {
for (var i = 0; i < str.length; i++) {
// charcodeat converts the alphabets to the character code (numbers that represent the given alphabets)
/* here u can find out the character code of each character, and looping through all of them tells you what is missing */
console.log(str.charCodeAt(i));
/* if code of current character is not equal to first character + no of iteration
hence character has been escaped */
if (str.charCodeAt(i) !== str.charCodeAt(0) + i) {
/* if current character has escaped one character find previous char and return */
// fromcharcode converts chacracter code it back to alphabet
return String.fromCharCode(str.charCodeAt(i) - 1);
}
}
return undefined;
}
// test here
console.log(whatIsMissing('bcdf'));
// Do a swap on the sentence using the arguments provided and return the new sentence.
// First argument is the sentence to perform the search and replace on (sentence)
// Second argument is the word that you want to change (before)
// Third argument is what you will be changing the second argument with (after)
// Preserve the case of the first character in the original word when you are replacing it. For example if you mean to replace the word "Book" with the word "dog", it should be replaced as "Dog"
// Hint 1: Check first letter case. toUpperCase()
// Hint 2: Find the index where before is in the string. indexOf()
// Hint 3: .splice()
// Hint 4: Make it into arrays first. Easier to manipulate.
// swap("His name is Tom", "Tom", "john") == "His name is John".
// swap("Let us get back to more Coding", "Coding", "algorithms") == "Let us get back to more Algorithms".
// swap("This has a spellngi error", "spellngi", "spelling") == "This has a spelling error".
function swap(str, pre, post) {
// Find index of pre
var preIndex = str.indexOf(pre);
console.log(preIndex);
console.log(str[preIndex]);
// Check to see if the first letter is uppercase or not
if (str[preIndex] === str[preIndex].toUpperCase()) {
// Change the post word to be capitalized before we use it.
post = post[0].toUpperCase() + post.slice(1);
} else {
// Change the post word to be uncapitalized before we use it.
post = post[0].toLowerCase() + post.slice(1);
}
// Now replace the original str with the edited one.
str = str.replace(pre, post);
return str;
}
console.log(swap('Let us get back to more Coding', 'Coding', 'algorithms'));
Also see: Tab Triggers