RC Tech Questions Flashcards
(61 cards)
What does a doctype do?
A doctype specifies which version of the markup language the page is written in. With the doctype declared, the browser determines how to render content correctly according to the page’s source code.
How do you serve a page with content in multiple languages?
To serve a page with content in multiple languages, use lang (or xml:lang for XHTML) in tags. Additionally, metadata and Content-Language HTTP header can be used.
What kind of things must you be wary of when designing or developing for multilingual sites?
When designing or developing for multilingual sites, there are a few things you should be wary of: 1) Allow users to change their language easily without hassle or confusion. 2) Content may be shorter or longer depending on the translation, so your design may break if it depends on character counts. 3) Be mindful of how colors are perceived culturally. 4) Format dates and currencies appropriately. 5) Some languages don’t follow English’s left-to-right, top-to-bottom reading direction.
What are data- attributes good for?
Data attributes are good for storing extra data within the DOM without having to use non-standard attributes or other hacks.
Consider HTML5 as an open web platform. What are the building blocks of HTML5?
The building blocks of HTML5 are: semantics (allowing you to describe precisely what your content is), connectivity (allowing communication with the server in new ways), offline and local storage, multimedia, performance and integration, device access, and styling.
Describe the difference between a cookie, sessionStorage and localStorage.
Cookies, sessionStorage and localStorage are all key-value storage mechanisms on the client side. They only store values as strings. Cookies can be initiated client or server side, while the others are client-only. Cookies’ expiry is manually set, localStorage persists forever, and sessionStorage expires when the tab closes.
Describe the difference between
,and.
<script> stops rendering, downloads and runs the script. <script async> doesn't stop rendering while downloading, but stops rendering to run when download completes. <script defer> doesn't stop rendering while downloading and runs the script only after rendering is complete. </script>
Why is it generally a good idea to position CSS <link></link>s between <head></head> and JS
s just before </body>?
It’s good to place CSS <link></link> in <head> because HTML and CSS will be parsed simultaneously when a page loads, allowing progressive rendering with proper visuals. JS
tags are better placed before the closing </body> tag because they block HTML/CSS parsing, so placing them at the end ensures content is displayed first.
What is progressive rendering?
Progressive rendering refers to techniques that improve webpage performance and perceived load time by rendering content for display as quickly as possible. Examples include lazy loading of images, prioritizing visible content, and async HTML fragments.
Why would you use a srcset attribute in an image tag?
You would use the srcset attribute to serve different images depending on device display width. This enhances user experience for high-resolution displays while improving performance for lower-end devices by serving appropriately sized images.
What is CSS selector specificity and how does it work?
Specificity is a weight applied to CSS declarations, determined by the number of each selector type. When multiple declarations target the same element, the one with higher specificity wins. Specificity hierarchy from highest to lowest: inline styles (a=1000), ID selectors (b=100), class/attribute/pseudo-class selectors (c=10), and type selectors (d=1).
What’s the difference between ‘resetting’ and ‘normalizing’ CSS?
Resetting CSS strips all default browser styling on elements, while normalizing preserves useful default styles and corrects bugs for browser dependencies. Resetting gives you more control for customized designs, while normalizing maintains consistency across browsers.
Describe floats and how they work.
Floats are a CSS positioning property that enable elements to remain part of the page flow. When elements are floated, they shift in the specified direction (left, right, none) and other content flows around them. Floated elements try to float to the uppermost available space of their containing element in that direction.
Describe z-index and how stacking context is formed.
Z-index controls the vertical stacking order of elements that overlap. It only affects positioned elements (not static). Elements with higher z-index appear on top. A stacking context is formed by elements with specific properties (like opacity<1, position:fixed), creating a hierarchy where z-index values only compete within their own context.
Describe BFC (Block Formatting Context) and how it works.
Block Formatting Context is part of CSS rendering that determines how block boxes are laid out. BFCs are created by elements like floats, absolutely positioned elements, and elements with overflow:hidden. BFCs contain floats, prevent margin collapsing between elements, and establish how elements are positioned within the same parent.
What are the various clearing techniques and which is appropriate for what context?
.clearfix is used when you have all floated elements within a containing element to make it take on the height of its content. Overflow:auto/hidden creates a new block formatting context but might clip children if they’re taller than the parent with a set height.
Explain CSS sprites, and how you would implement them on a page or site.
CSS sprites combine multiple images into one larger image to reduce HTTP requests. To implement, each image gets a CSS class with background-image, background-position and background-size properties. Add the corresponding class to elements to display the correct part of the sprite.
How would you approach fixing browser-specific styling issues?
To fix browser-specific styling issues: 1) Use a separate stylesheet that loads only for specific browsers, 2) Use libraries like Bootstrap that handle cross-browser compatibility, 3) Use autoprefixer for vendor prefixes, 4) Use Reset CSS or Normalize.css.
How do you serve your pages for feature-constrained browsers?
For feature-constrained browsers, use progressive enhancement - build for a base level of user experience and add enhancements when browsers support them. You can also use graceful degradation, tools like caniuse.com to check feature support, or CSS feature queries with @support.
What are the different ways to visually hide content for screen readers?
To hide content visually but keep it accessible to screen readers: 1) visibility:hidden (still takes up space), 2) width:0;height:0 (no space), 3) position:absolute;left:-99999px (positioned offscreen), 4) text-indent:-9999px (text only), 5) WAI-ARIA techniques.
Have you used or implemented media queries or mobile specific layouts/CSS?
Yes, I’ve used media queries and mobile-specific CSS on personal and client projects. Responsive Web Design ensures users across all devices can access and interact with content easily.
What are some of the ‘gotchas’ for writing efficient CSS?
For efficient CSS: 1) Understand browsers match selectors from right to left, so avoid tag and universal selectors as key selectors. 2) Use methodologies like BEM for efficient selectors. 3) Be aware of which CSS properties trigger reflow, repaint, and compositing.
What are the advantages/disadvantages of using CSS preprocessors?
Advantages of CSS preprocessors: logic in CSS (variables, nesting, mixins, functions), automation for repetitive tasks, reusable code, reduced errors. Disadvantages: requires preprocessing tools with compilation time, potentially writing non-standard CSS that requires transpilation.
How would you implement a web design comp that uses non-standard fonts?
To implement non-standard fonts in web design, use @font-face and define font-family for different font-weights, or use @import to bring in web fonts like Google Fonts.