4.33. Introduction to HTML: basic structure, tags and attributes: Promises and async/await

Página 37

Introduction to HTML: Basic structure, tags and attributes: Promises and async/await

Introduction to HTML

HTML, or HyperText Markup Language, is the standard markup language for documents designed to be displayed in a web browser. It is one of the core technologies of the World Wide Web and is an essential skill for any front-end developer.

Basic structure of an HTML document

The basic structure of an HTML document consists of nested tags. Each document begins with the <!DOCTYPE html> tag, which tells the browser that the following is an HTML5 document. Next, we have the <html> that involves the entire content of the page.

Within the <html> tag, we have two main parts: the <head> and <body>. The <head> contains metadata about the document, such as the page title, links to CSS stylesheets, and JavaScript scripts. The <body> contains the main content that is displayed in the browser.

HTML tags and attributes

HTML tags are the building blocks of any web page. They define the structure and layout of the content. Each tag begins with a angle bracket (<) and ends with an angle bracket (>). The most common tags include <h1> to <h6> for headers, <p> for paragraphs, <a> for links, <img> for images, and many more.

Attributes provide additional information about HTML elements. They come in name/value pairs and are always included at the beginning of the tag. For example, the link tag <a> usually comes with the 'href' attribute, which specifies the URL the link should point to.

Introduction to Promises and async/await in JavaScript

JavaScript is a programming language that allows you to add complex interactivity to websites. One of JavaScript's most powerful features is its ability to handle asynchronous operations, such as fetching data from a server. This is done using Promises and the async/await syntax.

Promises in JavaScript

A Promise in JavaScript is an object that represents the eventual completion or failure of an asynchronous operation. It serves as a proxy for a value that may not be known when the promise is created. A promise can be in one of three states: pending, fulfilled, or rejected.

Promises are used to handle asynchronous operations in a more flexible and robust way than old callbacks. They can be chained and manipulated in a way that avoids the so-called "callback hell", where we have many nested callbacks and the code becomes difficult to read and maintain.

Async/Await in JavaScript

async/await is a special syntax in JavaScript that makes working with Promises more comfortable and easier to understand. The 'async' keyword is used to declare a function as asynchronous, which means it will return a Promise. The 'await' keyword is used to pause the execution of the asynchronous function until the Promise is resolved or rejected.

Using async/await makes asynchronous code look more like synchronous code, which can make it easier to understand and maintain. However, it's important to note that although the code may appear synchronous, it still runs asynchronously, meaning it doesn't block the rest of the code from running.

Now answer the exercise about the content:

What is the function of the <head> in an HTML document?

You are right! Congratulations, now go to the next page

You missed! Try again.

Next page of the Free Ebook:

384.34. Introduction to HTML: basic structure, tags and attributes: Introduction to Node.js and NPM

Earn your Certificate for this Course for Free! by downloading the Cursa app and reading the ebook there. Available on Google Play or App Store!

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text