Introduction to HTML: Basic structure, tags and attributes
HTML, which stands for HyperText Markup Language, is the standard markup language for creating web pages and applications. Along with CSS and JavaScript, HTML is a fundamental technology used to create web content.
Basic structure of an HTML document
An HTML document has a tree structure. The root element is always the html element. Inside the html element, we have two child elements: the head and the body. The head element contains metadata about the document, such as its title and links to its scripts and CSS stylesheets. The body element contains the actual content of the document, such as text, images, videos, etc.
<!DOCTYPE html> <html> <head> <title>Page title</title> </head> <body> Page content </body> </html>
HTML tags and attributes
HTML elements are defined using tags. A tag is made up of the name of the element, surrounded by lower and upper characters. For example, <html>, <body>, <head>, <title>, etc.
Some HTML elements can also have attributes. Attributes provide additional information about the element. They are always specified at the beginning of the element tag and consist of a name and a value. For example, the a element, which is used to create links, has an href attribute that specifies the URL of the link.
<a href="https://www.example.com">This is a link</a>
Functions in JavaScript
JavaScript is a programming language that allows you to implement complex functions on web pages. When a web page is more than just static text and images, but interacts with the user, JavaScript is likely involved.
Functions are one of the fundamental building blocks in JavaScript. A function is a JavaScript procedure - a set of instructions that performs a task or calculates a value. To use a function, you must define it somewhere in the scope of where you want to call it.
Defining functions
A function in JavaScript is similar to a procedure - a set of instructions that performs a task or calculates a value, but for a function to be useful, it must be defined. The JavaScript function definition consists of a function keyword, followed by a name, a list of parameters enclosed in parentheses (brackets), and a declaration containing the code to be executed.
function functionname(parameter1, parameter2, parameter3) { // code to be executed }
Calling functions
Once you define a function, you can execute it by calling it from another part of your code. To do this, you use the function name followed by parentheses and provide the values (known as arguments) for the function's parameters.
FunctionName(value1, value2, value3);
We hope this basic information about HTML and JavaScript provides a solid foundation for you to continue learning and exploring these programming languages. Remember, practice is the key to becoming proficient, so keep practicing and building!