by Júlia Bacchi
1
2
3
4
Save and View
Save File: Press Ctrl + S (Windows/Linux) or Command + S (macOS) to save the file you’re editing. This ensures that all changes are recorded on disk. Refresh Page: After saving changes to your code, press Ctrl + R (Windows/Linux) or Command + R (macOS) to refresh the page in the browser and view the updates.
HTML Structure
Basic Structure: Type ! and press Enter, or html:5 and press Enter.
Navigation and Editing in VS Code
Search for Files and Commands: Use Ctrl + P (Windows/Linux) or Command + P (macOS) to open the quick search bar and find files or execute commands. Global Search: To search for a word or phrase throughout the project, use Ctrl + Shift + F (Windows/Linux) or Command + Shift + F (macOS). Switch Between Open Files: Use Ctrl + Tab (Windows/Linux) or Command + Tab (macOS) to switch between open files in VS Code.
Development Tools
Inspect Elements: Use Ctrl + Shift + I (Windows/Linux) or Command + Option + I (macOS) to open the developer tools in the browser and inspect the HTML and CSS structure of the page.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Page</title>
</head>
<body>
<h1>Welcome to HTML!</h1>
<p>This is a paragraph of text.</p>
<a href="https://www.example.com" target="_blank">Visit our site</a>
<img src="image.jpg" alt="Image Description">
</body>
</html>
Text Formatting Tips
Italic: <em>SheCodes Workshops</em> Bold: <strong>SheCodes Workshops</strong> Line Break: Welcome to my website<br /> We hope you enjoy your stay Section Separator: Welcome to my website<hr /> Discover latest updates below
<header>
<h1>My Website</h1>
</header>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
</ul>
</nav>
<main>
<p>Main content of the page.</p>
</main>
<footer>
<p>© 2024 My Website</p> </footer>
Tips!Organization: Use <div> to organize your code into logical sections, making maintenance and understanding easier.Semantics: When possible, use more semantic HTML5 tags, such as <header>, <section>, and <footer>, to make content more accessible and improve SEO (Search Engine Optimization).
<img>
tag to insert images into your pages.<img src="path/to/image.jpg" alt="Image Description">
.image {
max-width: 100%; height: auto;
}
<i class="fab fa-instagram"></i>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
<form action="/submit"> <label for="name">Name:</label>
<input type="text" id="name" name="name">
<input type="submit" value="Send"> </form>
<p class="description">This is an example of how to use classes in CSS to style different elements.</p>
<p class="description">Classes allow you to apply common styles to multiple elements.</p>
.description {
color: #666;
font-size: 1.2em;
line-height: 1.6;
margin-bottom: 15px;
}
<header id="header">
Welcome to My Website
</header>
#header {
background-color: blue;
color: white;
padding: 20px;
text-align: center;
}
text-align: left | right | center | justify | initial | inherit;
Font-size: Sets the size of the font (px)
Font-weight: Defines the thickness of the font (numbers 100, 200 or normal | bold | bolder | lighter)
Font-family: Georgia, serif;
text-decoration: underline;
background: green;
background: linear-gradient(#e66465, #9198e5);
color: blueviolet;
color: #00ff00;
color: rgb(135, 93, 241);
color: rgba(135, 93, 241, 0.5);
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>External JavaScript Example</title>
</head>
<body>
<h1>Hello, World!</h1>
<script src="script.js"></script> <!-- Includes the external JavaScript file -->
</body>
</html>
console.log('External JavaScript is working!');
1
2
3
4
5
6
7
8
function greet(name) {
return Hello, ${name}!;
}
console.log(greet("Alice")); // Hello, Alice!
function add(a, b) {
return a + b;
}
console.log(add(5, 3)); // 8
let header = document.querySelector("h1");
header.textContent = "New Title";
document.querySelector("#button").addEventListener("click", function() { alert("Button clicked!");
});
#
in the selector indicates that we are targeting a specific ID.