How websites work Flashcards
To exploit a website, you first need to know how they are created.
What role does the browser play in accessing a website?
- It serves as a server to host the website content.
- It renders the website based on the data received from the server.
- It acts as the internet, transferring data across the world.
- It generates content for the website internally without contacting a server.
It renders the website based on the data received from the server.
Explanation: The browser, also known as the client, sends requests to a web server and receives data in response. The browser then interprets this data (such as HTML, CSS, and JavaScript) and renders the website for the user to interact with.
What is the primary function of a web server in the context of website interaction?
- To render web pages for the client.
- To store and process requests from the browser and send the appropriate data back.
- To act as a user interface for website navigation.
- To provide a secure connection between different browsers.
To store and process requests from the browser and send the appropriate data back.
Explanation: A web server’s main function is to store website files and process incoming requests from clients (browsers). When a request is received, the server retrieves the requested data and sends it back to the client for rendering.
When visiting a website, what does the browser request from the server?
- The server’s physical location and specifications.
- The entire database of the website for local processing.
- Specific information about the page you’re visiting to render it for you.
- Permanent storage of the website’s data on the client’s computer.
Specific information about the page you’re visiting to render it for you.
Explanation: When you visit a website, the browser sends a request to the web server for specific data about the page you want to view. The server responds with this data, which typically includes HTML, CSS, and JavaScript files that the browser uses to render the page.
What are the two major components that make up a website?
- Internet and Server
- Browser and Operating System
- Front End (Client-Side) and Back End (Server-Side)
- Database and User Interface
Front End (Client-Side) and Back End (Server-Side)
Explanation: A website consists of two main components: the front end, or client-side, which is what the user interacts with directly in the browser; and the back end, or server-side, which includes the server and its software that process requests, access databases, and serve website data.
How does the ‘Internet’ component fit into the process of accessing a website?
- It is the physical computer that the browser runs on.
- It is the software that renders the web pages.
- It is the network that facilitates the transfer of data between the browser and the server.
- It is the coding language that websites are written in.
It is the network that facilitates the transfer of data between the browser and the server.
Explanation: The Internet is a global network that connects computers all over the world. In the context of accessing a website, it is the medium through which data is transferred from the web server to the user’s browser and vice versa.
What is the purpose of the <!DOCTYPE html>
declaration in an HTML document?
- To link a CSS stylesheet to the HTML page.
- To define a comment within the HTML code.
- To declare the character encoding of the HTML document.
- To specify the HTML version being used to the browser.
To specify the HTML version being used to the browser.
Explanation: The <!DOCTYPE html>
declaration is used to inform the browser that the document is an HTML5 document. It is not an HTML tag; rather, it is an instruction to the web browser about what version of HTML the page is written in.
What does the <html>
tag represent in an HTML document?
- The title of the webpage.
- The root of an HTML document that contains all other elements.
- The main content that is displayed in the browser window.
- A reference to an external JavaScript file.
The root of an HTML document that contains all other elements.
Explanation: The <html>
tag is the root element of an HTML document. All other HTML elements must be descendants of this element.
What is contained within the <head>
element of an HTML document?
- The content that is displayed in the main part of the browser window.
- Metadata about the document, such as its title and links to scripts and stylesheets.
- A declaration of the document type and version.
- The navigation links for the website.
Metadata about the document, such as its title and links to scripts and stylesheets.
Explanation: The <head>
element contains metadata about the HTML document, which includes the title of the page, links to CSS files, scripts, and other information that is not displayed directly on the web page.
What does the <body> tag in an HTML document define?
The main content of the HTML document that is visible to the user.
The background information and configuration settings for the webpage.
The connection settings for the server.
The scripts and algorithms for client-side interactions.
The main content of the HTML document that is visible to the user.
Explanation: The <body>
tag defines the body of the HTML document and contains all the contents of an HTML document, such as text, hyperlinks, images, tables, lists, etc., that are displayed on the web page.
What is the function of the <h1>
element in an HTML document?
- To create a hyperlink to another document.
- To define a top-level heading in the HTML document.
- To insert an image into the webpage.
- To emphasize a section of text.
To define a top-level heading in the HTML document.
Explanation: The <h1>
element is used to define the most important heading in an HTML document. There are six levels of headings in HTML, with <h1>
being the highest, or most important, level.
How is a paragraph represented in HTML?
- Using the
<h1>
tag. - Using the
<p>
tag. - Using the
<body>
tag. - Using the
<div>
tag.
Using the <p>
tag.
Explanation: The <p>
tag defines a paragraph in an HTML document and is used to group together related sentences into a block of text separated from adjacent blocks by vertical whitespace and, optionally, a first line indentation.
What is the purpose of attributes in HTML elements?
- To specify the version of HTML used.
- To define the character set for the document.
- To provide additional information about elements, such as style, location, or identification.
- To comment out sections of code for documentation purposes.
To provide additional information about elements, such as style, location, or identification.
Explanation: Attributes in HTML elements are used to provide additional information about the element. Attributes are always specified in the start tag and usually come in name/value pairs like name="value"
.
If you want to style a paragraph element with a unique style, which attribute should you use?
class
src
id
href
id
Explanation: The id
attribute is used to assign a unique identifier to an HTML element. It is commonly used for styling with CSS and for manipulation with JavaScript. Unlike the class
attribute, which can be used on multiple elements, each id
value must be unique within the HTML document.
What is the primary use of JavaScript in web development?
- To define the structure of a webpage.
- To style HTML elements on a page.
- To create interactive elements on a webpage that can respond to user actions.
- To specify the protocol for how the page communicates with the server.
To create interactive elements on a webpage that can respond to user actions.
Explanation: JavaScript is primarily used to add interactivity to web pages. It can respond to user actions like clicks, form submissions, and mouse movements, and can dynamically update the content, style, and functionality of a webpage without the need for a full page refresh.
Where can you include JavaScript in an HTML document?
- Only at the top of an HTML document.
- Inside
<style>
tags. - Within
<script>
tags or remotely using the src attribute in a<script>
tag. - As an attribute of any HTML tag.
Within <script>
tags or remotely using the src attribute in a <script>
tag.
Explanation: JavaScript can be embedded directly into HTML using <script>
tags or included as an external file through the src attribute of the <script>
tag. This flexibility allows the developer to organize and maintain JavaScript code effectively.