HTML/CSS Flashcards
What is the difference between HTML, CSS, and JavaScript?
HTML (Hypertext Markup Language) is used for structuring and presenting the content of a web page.
CSS (Cascading Style Sheets) is used for styling and layout of the HTML elements.
JavaScript is a programming language that allows for interactivity and dynamic behavior on web pages.
What is the box model in CSS?
The box model in CSS describes the layout and sizing of elements. It consists of the content area, padding, border, and margin. The total width and height of an element are calculated as the sum of its content, padding, border, and margin.
What is responsive web design, and how do you achieve it?
Responsive web design is an approach to create websites that adapt to different screen sizes and devices. It ensures that the content and layout adjust automatically to provide the best user experience. Achieving responsiveness involves using fluid layouts, flexible images, and media queries in CSS.
What are media queries in CSS, and how do they work?
Media queries are CSS features that allow different styles to be applied based on various device characteristics such as screen width, height, and resolution. They are used to create responsive designs by defining different CSS rules for different screen sizes or devices.
What are the different ways to include CSS in a web page?
CSS can be included in a web page in several ways, including external style sheets, internal style sheets, and inline styles.
What is the box model in CSS?
- The box model is a model used by CSS to represent the layout of a web page.
- It consists of four parts: content, padding, border, and margin.
What is the difference between margin and padding in CSS?
- Margin is the space outside of an element’s border, while padding is the space inside of an element’s border.
- Margin can be used to create space between elements, while padding can be used to create space within an element.
What is a CSS selector?
- A CSS selector is a pattern used to select elements in a web page.
- It can be based on the element’s tag name, class, ID, or other attributes.
What is the difference between a class and an ID in CSS?
- A class can be applied to multiple elements, while an ID can only be applied to one element.
- IDs are typically used to target a specific element, while classes are typically used to group elements together and apply styles to them.
What is a pseudo-class in CSS?
- A pseudo-class is a keyword added to a selector that specifies a special state of the selected element.
- Examples of pseudo-classes in CSS include :hover, :active, and :focus.
What is the float property in CSS?
- The float property is used to position an element to the left or right of its container.
- It is often used to create columns in a web page layout.
What is the difference between em and rem units in CSS?
- The em unit is based on the font size of the parent element, while the rem unit is based on the font size of the root element.
- Rem units are often used in responsive layouts because they are not affected by changes in the font size of the parent element.
What is a doctype in HTML?
A doctype is a declaration at the beginning of an HTML document that tells the browser which version of HTML is being used.
What is the difference between a div and a span in HTML?
- A div is a block-level element that is used to group other elements together and apply styles to them.
- A span is an inline-level element that is used to apply styles to a specific part of a text.
What is a hyperlink in HTML?
- A hyperlink is a link that connects one web page to another.
- It is created using the
<a>
tag and the href attribute.