HTML/CSS Flashcards

1
Q

What is Semantic HTML?

A

Semantic HTML is the use of HTML tags that provide a clear purpose of the content’s role within a webpage.
They make your website code more understandable for both developers and search engines.

For example, <header>is a semantic HTML tag. It encloses the header section (introductory content) at the top of the page.

Examples:

<h1></h1>

<nav></nav>

<ul></ul>

<footer></footer>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Non-Semantic HTML?

A

Non-semantic HTML tags are generic and primarily used for styling and layout purposes.

Non-semantic HTML tags don’t convey any specific meaning about the content itself.

Examples:

<div></div>

<span></span>
<a></a>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain how HTML, CSS, and JavaScript work together?

A
  1. he browser starts by reading and parsing the HTML from top-to-bottom to create the DOM tree (It is a representation of the HTML content structure where each element is a node in the DOM tree. Each element, attribute, and text becomes an object in the DOM tree that can be accessed and manipulated by JavaScript later on.)
  2. Then it reads/parses the CSS file and constructs a CSSOM (CSS Object Model), it organizes it into a hierarchical structure.
  3. The DOM and the CSSOM are merged into a Render Tree, which contains only visible elements with their applied styles.
  4. Then the browser determines the exact position of each visible element based on the Render Tree and paints it on the browser screen pixel by pixel.
  5. Lastly, JavaScript is parsed and executed separately through the
    . JavaScript can modify the DOM, change CSS, and fetch new content dynamically. When this happens, the browser may need to recalculate the layout and repaint parts of the screen.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is HTTP? What are other HTTP types that are out there?

A

What is HTTP?

HTTP (Hypertext Transfer Protocol) is a form of data communication between the web browsers and servers. It is built off of TCP/IP on the application-layer protocol. It transports web pages, media, and other resources.

Model type:

HTTP operates on a request-response model: the client sends requests to servers, which then responds with the requested data. The protocol is stateless, meaning each request is independent of any previous requests.

Method Types:

HTTP supports different types of methods to interact with resources: (GET, POST, PUT, DELETE, etc.)

Security:

HTTPS uses encryption to protect data in transit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the ways to add images to html? Be specific!
Example: Explaining how to add to the src attribute.

A
  • <img></img> element
  • <Picture> element for responsive design

    </Picture>
  • CSS background-image on an element
  • Inline SVG: embed SVG into HTML
  • <object> for svg or external files

    </object>
  • <embed></embed>for embedding svg’s
  • <iframe> Embedding images for another site.

    </iframe>
  • Data URL (base64-encoded image)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are HTML attributes? Can you give an example?

A

The information inside an html element defining rules for it.

Example,
href=””,
src=””,
style=””,
type=””,
etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between <div> and <span>?</span>

A

<div> is a block-level element for grouping and structuring larger sections of a webpage.

<span> is an inline element for styling or manipulating a small portion of text within a larger block of content.
</span></div>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of the <head> tag in HTML?

A

To provide meta data and background information for the HTML file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is block-level and inline in HTML? What are some common block-level and inline elements in HTML?

A

A block-level takes up a full width of its parent container by default. It starts a new line and pushes the next elements down.

An Inline element only takes up as much width as necessary. It does not start a new line. It stays within flow of the surrounding text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the difference between <strong> and <b>, <em> and <i>?</i></em></b></strong>

A

The difference between the two is that <strong> is a semantic element for search engines. Whereas <b> is just a regular, non-semantic element. They both embolden the text.</b></strong>

The same with <em> and <i> with italicizing the text. <em> which stands for emphasis, is a semantic element whereas <i> is not.</i></em></i></em>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

If you have a nested div within a div and they both have an id or class, how do you change the inner div?

A

With CSS selectors. You would tag the inner div with its id name, since it is unique. The parent div could have the same class. With that id name selected, you can change the inner div.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is CSS and why is it used?

A

CSS (Cascading Style Sheets) is a stylesheet language used for describing the presentation of a web page written in HTML or XML.

CSS is used to enhance the visual appearance and user experience of web pages through responsive design, layout, colors, fonts, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the different types of CSS? (Inline, Internal, External)

A

Inline: Is CSS written within the individual elements <> in the HTML file
Internal: Is writing it in the head of the HTML structure
External: Is linking an external CSS file to the HTML file to style it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between id and class in CSS?

A

An id is unique per HTML document file and is used to identify a single element.

A class is used to identify multiple elements with the same class. Is used to apply the same styling or behavior to multiple elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What’s the difference between relative, absolute, fixed, and sticky positioning?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How does the float property work?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the z-index property do in CSS?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How does the Internet work?

A

The Internet works through a global network of interconnected computers and servers, communicating via standardized protocols. Data is broken into packets and routed through various network nodes using the Internet Protocol (IP). These packets travel across different physical infrastructures, including fiber optic cables, satellites, and wireless networks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is Domain Name System (DNS)?

A

DNS is crucial for the functioning of the Internet, enabling users to access websites and services using memorable names instead of numerical IP addresses.

The system uses a tree-like structure with root servers at the top, followed by top-level domain servers (.com, .org, etc.), second-level domain (usually the website or organization name), and local DNS servers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the Box Model?

A

The fundamental concept that describes how elements are rendered on a webpage. Every HTML element is treated as a rectangular box, and the box model defines how the size of this box is calculated, including content, padding, border, and margin.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is HTML?

A

HTML stands for HyperText Markup Language. It structures web content and allows the inclusion of text, images, links, and other elements on the screen.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are HTML tags?

A

HTML tags are the building blocks of HTML. They are used to create elements and structure content on a web page. Tags are enclosed in angle brackets, For example, <p> for a paragraph. Most tags come in pairs: an opening tag <p> and a closing tag </p>.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is the basic structure of an HTML document?

A

<!DOCTYPE html>: Declares the document type and version of HTML.

<html>: The root element of the document.

<head>:Contains meta-information about the document, such as the title and links to stylesheets.

<title>: Specifies the title of the document, displayed in the browser’s title bar.

<body>:Contains the content of the document, such as text, images, and other elements.
</body></title></head></html>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is the purpose of a DOCTYPE declaration in HTML5?

A

The DOCTYPE declaration in HTML5 is used to specify the document type and version of HTML that the web page is written in.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is the difference between an element and a tag in HTML?

A

A tag is a part of HTML syntax used to define elements. Tags are enclosed in angle brackets, e.g., <div>.

An element consists of a start tag, content, and an end tag. For example, <p>This is a paragraph.</p> is a paragraph element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What are attributes in HTML?

A

Attributes provide additional information about HTML elements. They are included within the opening tag and usually come in name-value pairs, like name=”value”.

For example, in <a href=”https://www.example.com”>Link</a>, href (hypertext reference) is an attribute specifying the URL of the link.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

How do you create a hyperlink in HTML?

A

To create a hyperlink, use the <a> (anchor) tag with the href attribute specifying the URL.</a>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What are other ways to create a hyperlink in HTML?

A

-Through a form’s action attribute
- Through the use of buttons
- Through the <link></link> tag for attaching stylesheets and resources
- window.location
- <meta></meta>
- Using an image as a hyperlink
- Using <area></area> inside of <map> for clickable image maps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is a Hypertext?

A

A hypertext is text that contains links (called hyperlinks) to other text, documents, or resources. Unlike regular text, hypertext allows users to navigate between different pieces of information by clicking on links.

30
Q

What is the <title> tag used for?</title>

A

The<title> tagdefines the title of the HTML document, which appears in the browser’s title bar or tab. It’s placed within the <head> section.</title>

31
Q

What is the purpose of the <img></img> tag in HTML?

A

The <img></img> tag is used to embed images in an HTML document.

The src=”” is the image file path name and the alt=”” is the alternative description of the image when the image isnt loaded.

32
Q

What is the difference between block-level and inline elements in HTML?

A

-Block-level elements:These elements start on a new line and take up the full width available. Examples include <div>, <p>, and <h1> to <h6>.

  • Inline elements:These elements do not start on a new line and only take up as much width as necessary. Examples include<span>,<a>, and <img></img>.</a></span>
33
Q

How do you create a list in HTML?

A
  • Ordered List: Creates a numbered list using the <ol> tag.
  • Unordered List:Creates a bulleted list using the <ul> tag.
34
Q

What is the purpose of the <br></br> tag?

A

<br></br> tag: inserts a line break in the text, moving the content after the tag to a new line. It’s an empty tag and doesn’t require a closing tag.

35
Q

How do you create a hyperlink that opens in a new tab?

A

To open a link in a new tab, use the target attribute with the value _blank:

<a>Visit Example</a>

36
Q

What is the <title> tag used for?</title>

A

The<title> tagdefines the title of the HTML document, which appears in the browser’s title bar or tab. It’s placed within the <head> section.</title>

37
Q

What is the purpose of the <meta></meta> tag?

A

The<meta></meta> tagprovides information about the HTML document, such as character set, author, description, and keywords to create better user experiences, SEO, accessibility, and control search engine behavior. It’s placed within the <head> section.

38
Q

How do you specify the character encoding for an HTML document?

A

The character encoding is specified using a <meta></meta> tag within the <head> section:

<meta></meta>

39
Q

What is the difference between <head> and <body> tags?

A

<head>:Contains meta-information about the document, such as the title, character set, and links to stylesheets and scripts.

<body>:Contains the actual content of the document that is displayed in the browser, such as text, images, and links.
</body></head>

40
Q

What is the difference between the <b> and <strong> tags?</strong></b>

A

Both tags display text in bold, but <strong> indicates that the text is of strong importance, providing semantic meaning, while <b> does not convey any extra importance.</b></strong>

41
Q

How do you embed a video in HTML5?

A

HTML5 provides the <video> tag to embed videos:</video>

controls:Adds video controls like play, pause, and volume.

source: Specifies the video file and its format.

<video>
<source></source>
Your browser does not support the video tag.
</video>

42
Q

How do you create an email link in HTML?

A

To create a link that opens the user’s default email client with a new message, use the mailto: scheme:

<a>Send Email</a>

43
Q

What is the purpose of the <noscript> tag in HTML?</noscript>

A

The<noscript> defines alternative content to be displayed if the user’s browser does not support JavaScript or if JavaScript is disabled.</noscript>

<noscript>
<p>JavaScript is not enabled in your browser.</p>
</noscript>

44
Q

What is the purpose of the action attribute in an HTML form?

A

The action attribute specifies the URL to which the form data will be submitted when the form is submitted.

45
Q

What is the difference between the “id” and “class” attributes in HTML5?

A

id attribute

  • Each id must be unique within a document.
  • Used to identify a single element.

class attribute

  • Multiple elements can have the same class.
  • Used to apply the same styling or behavior to multiple elements.
46
Q

What is the purpose of the “alt” attribute in HTML5?

A

To provide an alternative text or image or resource when the original source cannot be loaded.

47
Q

How do you create a numbered list in HTML?

A

Use the <ol> (ordered list) tag, with each list item defined by <li>:

<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>

48
Q

What is the purpose of the <base></base> tag in HTML?

A

The<base></base> tagspecifies the base URL for all relative URLs in a document. It must be included inside the <head> section.

<base></base>

49
Q

How do you create a definition list in HTML?

A

Use the <dl> tag for the list, <dt> for each term, and <dd> for each definition:

<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>

50
Q

What is the purpose of the enctype attribute in an HTML form?

A

The enctype attribute specifies how form data should be encoded when submitting it to the server. It’s used with the method=”post” attribute.

<form>
<!-- form elements -->
</form>

51
Q

How do you create a hidden input field in an HTML form?

A

Use <input type=”hidden”> to create a hidden input field that stores data without displaying it to the user:

<input></input>

52
Q

What is the purpose of the <address> tag in HTML?

A

The <address> tag is used to define contact information for the author or owner of a document or article.

53
Q

What is the purpose of the <address> tag in HTML?

A

The <address> tag is used to define contact information for the author or owner of a document or article.

<address>
Written by John Doe.<br></br>
Visit us at:<br></br>
Example.com<br></br>
Box 564, Disneyland<br></br>
USA
</address>

54
Q

What is the purpose of the <canvas> element in HTML5?</canvas>

A

The <canvas> element provides a drawable region in the document that can be used to render graphics, such as charts, games, or other visual images, on the fly via scripting (usually JavaScript).</canvas>

<canvas></canvas>

55
Q

What is the difference between <i> and <em> tags?</em></i>

A

Both provide italics styling but <i> is non-semantic, while <em> is semantic html which helps provide better accessibility and SEO. <em> stands for “Emphasis”.</em></em></i>

56
Q

What is the difference between <b> and <strong> tags?</strong></b>

A

Both provide bold styling but <b> is non-semantic, while <strong> is semantic html which helps provide better accessibility and SEO.</strong></b>

57
Q

How do you specify multiple language versions of a webpage?

A

To provide multiple language versions of a webpage, you can use the hreflang attribute in the <link></link> tag to specify the language of an alternate version. This helps search engines understand and serve the correct language version to users.

58
Q

How can you include SVG graphics directly in an HTML document?

A

Scalable Vector Graphics (SVG) can be embedded directly within HTML using the <svg> tag. This allows for defining vector-based graphics that can scale without loss of quality.</svg>

<svg>
<circle></circle>
</svg>

59
Q

What are data attributes in HTML, and how are they used?

A

Data attributes in HTML are custom attributes that start with data- and allow you to store extra information on HTML elements. They are often used to embed custom data that can be accessed via JavaScript.

<div>User Info</div>

In JavaScript, you can access these attributes using the dataset property:

const div = document.querySelector(‘div’);
console.log(div.dataset.userId); // Outputs: 12345
console.log(div.dataset.role); // Outputs: admin

60
Q

Explain the purpose of the <template> tag in HTML.</template>

A

The <template> tag is used to declare a fragment of HTML that is not to be rendered immediately when the page loads. Instead, it can be instantiated later using JavaScript. This is useful for client-side templating.</template>

<template>
<div>
<h2></h2>
<p></p>
</div>
</template>

JavaScript can then be used to clone and insert the template content into the document.

61
Q

How do you specify multiple language versions of a webpage?

A

To provide multiple language versions of a webpage, you can use the hreflang attribute in the <link></link> tag to specify the language of an alternate version. This helps search engines understand and serve the correct language version to users.

<link></link>

<link></link>

62
Q

What is the purpose of the <output> tag in HTML?</output>

A

The <output> tag represents the result of a calculation or user action. It’s typically used in conjunction with forms to display the outcome of user interactions.</output>

63
Q

What is the purpose of the <output> tag in HTML?</output>

A

The <output> tag represents the result of a calculation or user action. It’s typically used in conjunction with forms to display the outcome of user interactions.</output>

<form>
<input></input> +
<input></input>
= <output>0</output>
</form>

64
Q

How can you make an HTML element editable in the browser?

A

To make an HTML element editable directly in the browser, you can set the contenteditable attribute to true. This allows users to edit the content of the element in place.

65
Q

What is the purpose of the <datalist> tag in HTML?</datalist>

A

The <datalist> tag is used to provide a list of predefined options to an <input></input> element, typically used to offer autocomplete suggestions.</datalist>

<label>Choose your browser:</label>
<input></input>

<datalist>
<option>
<option>
<option>
<option>
<option>
</datalist>

When the user starts typing in the input field, the browser will display the options defined in the <datalist> that match the current input.
</datalist></option></option></option></option></option></datalist>

66
Q

What is the order property in CSS? How does it work?

A

Order Property controls the visual order of items inside a flex container. It does not change the order in the HTML, only how items appear.

Default Order = 0 (All flex items have order: 0 by default).
Lower order appears first (Negative numbers move items to the front).
Higher order appears later (Bigger numbers move items to the back).

When to Use order?
✅ When you need to rearrange elements visually without modifying HTML.
✅ Useful for responsive designs where you want items to shift on different screen sizes.

67
Q

What is the difference between align-self and align-items in CSS?

A

Align-items affects a whole container.
Align-self is for individual selectors.

68
Q

Explain flex-flow property in CSS?

A

It is a shorthand combination of flex-direction and flex-wrap.

Ex. flex-flow: row wrap

69
Q

What does align-content do in CSS?

A

It sets how multiple lines (or rows) are spaced apart from eachother. It uses the same property values as align-items.

70
Q

What is the difference between align-content and align-items?

A

align-content determines the spacing between lines

align-items determines how the items as a whole are aligned within the container.