Technical Questions Flashcards
What does doctype do?
Doctype is the abbreviation for the document type, Doctype declaration tells the browser
what kind of document to expect. If you don’t declare the doctype, browsers can interpret the document as something else other than HTML
How do you serve a page with content in multiple languages?
We can set the language in the HTML document by setting the lang attribute in the code. By default, the specified language is English, but it can be changed at our convenience.
By default:
You can set the whole site as being english by setting the html element Or you could set a paragraph as spanish with <p></p>
What kind of things must you be wary of when design or developing for
multilingual sites?
- Sentence length/Text overflow when translated
- Formatting Dates Calendar dates are sometimes presented in different ways For Example, May 31, 2012 in the US. vs “31 May 2012” in parts of Europe.
- Text In Images Won’t Scale
- Be Mindful af How Colors Are Perceived Across Different Cultures
What are data- attributes good for?
Explanation: They store data private to the page or application
Use: They were often used for storing extra data in the DOM, but are generally discouraged now.
Consider HTML5 as an open web platform. What are the building blocks of
HTML5?
- Semantics: allowing you to describe more precisely what your content is.
- Connectivity: allowing you to communicate with the server in new and innovative ways.
- Offline and storage: allowing webpages to store data on the client-side locally and operate offline more efficiently.
- Multimedia: making video and audio first-class citizens in the Open Web
- 2D/3D graphics and effects: allowing a much more diverse range of presentation options.
- Performance and integration: providing greater speed optimization and better usage of computer hardware.
- Device access: allowing for the usage of various input and output devices
- Styling: letting authors write more sophisticated themes
Describe the difference between a cookie, sessionStorage and localStorage
the server with HTTP request.
sessionStorage and losalStorage are initiated by the client and aren’t sent to the server.
The main difference is that localStorage will stay forever until it Is cleared manually.
Describe the difference between script, script async, and script defer
HTML parsing is blocked, script is fetched and executed immediately.
- async scripts load in the background and run when ready. The DOM and other scripts don’t wait for them, and they don’t wait for anything. A fully independent script that runs when loaded.
The defer attribute tells the browser not to wait for the script. The script loads “in the background”, and then runs when the DOM is fully built
Why is it generally a good idea to position CSS «link»s between ¿head» «/head>
and JS «script>s just before
Putting <1ink>s in the chead» allows for quick “first meaningful paint”. When a page first loads, HTML and CSS are being parsed simultaneously. Conversely script> tags block HTML parsing while they are being downloaded and executed which can slow down your page. Placing the scripts at the bottom will allow the HTML to be parsed and displayed to the user first.
Exceptions: When your script contains document. write, however it isn’t consider good practice to use document. rite Also if you need scripts to run on page load it may be beneficial to split them out from your main script and place in the head.
What is progressive rendering?
Explanation: Techniques used to improve the performance of a webpage to render content for display as quickly as possible.
Use: Improving percerved load time
Example: Lazy loading of images. Prioritizing visible content (or above-the-fold rendering) and Async HIM fragments
Why you would use a srcset attribute in an image tag? Explain the process the
browser uses when evaluating the content of this attribute
Explanation: When you want to serve different images to users depending on their device display width.
Use: Sending lower resolution to limut data waste and increase performance or sending larger images to a higher resolution display to enhance the UX
Example: < img srcset=”omall.jpg 500w. mediun.jpg 1000w, large.jog 2000w” arC=”
“ alt=“”>
Have you used different HTML templating languages before?
EJS and React (JSX)
What is CSS selector specificity and how does it work?
Explanation: The means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied.
Use: Specificity is a weight that is applied to a given CSS declaration, determined by the number of each selector type in the matching selector.
Example: A selector of #id .class tag would have 111 points as id’s count for 100, classes for 10 and tags 1.
What’s the difference between “resetting” and “normalizing” CSS? Which would you choose, and why?
Explanation: “Normalize” alters the default styles of various browser to match each other. “Reset” will remove the browsers default styles so you are starting from scratch.
Use: Applying one or the other is done to try and make websites visually consistent across different browsers. I prefer to use a mix of both. Starting with the normalize to keep it conscise and then add some elements like anchors and headers with a reset. Going full “nuke” is often unnecessary and creates a larger, harder to debug file.
Describe floats and how they work.
Explanation: Floats are a positioning property where the element that is floated will be removed from the flow of the page and affect the elements around it. A parent element will collapse to zero height if it contains only floated elements, to fix this it was common to use a .clearfix hack.
Use: It was used prior to flex and grid to layout pages in a more flexible manner.
Example: You could float three elements left and give them widths of 33% to create three even width columns.
Describe z-index and how stacking context is formed
Explanation: The z-index property in CSS controls the vertical stacking order of elements that overlap. A stacking context is an element that contains a set of layers. The z-index values of its children are set relative to that element rather than to the document root. Layers outside of that context can’t sit between layers within it.
Describe BFC (Block Formatting Context) and how it works.
Explanation: A BFC is an HTML box that satisfies at least one of the following conditions:
The value of float is not none.
The value of position is neither static nor relative.
The value of display is table-cell, table-caption, inline-block, flex, or inline-flex, grid, or inline-grid.
The value of overflow is not visible.
Use: Knowing how to establish a block formatting context is important, because without doing so, the containing box will not contain floated children.
Example: Without forming a BFC you could have content of a float that is taller than the content alongside it. The border of the parent element could then “cut-through” the floated box.
What are the various clearing techniques and which is appropriate for what
context?
Explanation:
Empty div method
Clearfix method
overflow: auto or overflow: hidden method
Use: .clearfix utility class is probably the best method to use in general as it doesn’t take long to construct and doesn’t suffer from clipping issues like the overflow methods.
Explain CSS sprites, and how you would implement them on a page or site.
Explanation: CSS Sprites are a means of combining multiple images into a single image file for use on a website, to help with performance.
Use: Browsers limit the number of concurrent requests a site can make so leading several images with a single HTTP request helps increase page load speed.
Example: An example would be combining press logo’s for Wired, NY Times and The Washington Post into a single image file. Then on the site, with CSS, placing the file three times and moving/cropping it to display the applicable logo.
How would you approach fixing browser-specific styling issues?
Explanation: There are a handful of ways to solve the issue such as browser specific stylesheets, using a library like bootstrap, etc. MY preference would be to use a combination normalize/reset style sheet. I’d rather use a combination as going full nuke with a reset isn’t necessary and makes it a little harder to debug.
How do you serve your pages for feature-constrained browsers? What techniques/processes do you use?
Explanation: My preference is to try and build lightweight simple websites that incorporate progressive enhancement.
Use: Build the base level of HTML/CSS with semantics and accessibility in the forefront you get a site that works well on feature-constrained browsers. I would then add any CSS on JavaScript enhancements deliberately, checking caniuse.com and using vendor prefixs and polyfills if required.
Example: Instead of filling the site with <div> using more semantically appropriate tags like </div>
What are the different ways to visually hide content (and make it available only for screen readers)?
One of the ways is to tell CSS to display nothing or to make something hidden:
display:none; or visibility: hidden;
Another way is to set the literal content to 0 pixels so that whatever is written in the HTML has no value in pixels to be displayed:
width: 0px; Height 0px;
Yet another way is the move the visible content off of the visible screen.
Text-intent: -10000px;
Moving the content off screen is a great way to hide the content from the sighted user but keeps it available for the screen readers.
Have you ever used a grid system, and if so, what do you prefer?
The float-based grid system was the most reliable because it still has the most browser support among the alternative existing systems (flex, grid). Bootstrap was using the float approach until Bootstrap 4 which switched to the flex-based approach. Flex is the recommended approach for building grid systems and has decent browser support. But I am almost confident that with the broader adoption of CSS Grid, it will turn into the main layout standard.
Have you used or implemented media queries or mobile specific layouts/CSS?
Explanation: I use them quite frequently.
Use: I use them on every website and typically build mobile first. The breakpoints and media queries are then used to convert the layout from mobile to desktop.
Example: Some examples is changing a bunch of cards from being a single column stack on mobile to a three column layout on desktop.
Are you familiar with styling SVG?
Scalable Vector Graphics (SVG) are an XML-based markup language for describing two-dimensional based vector graphic
Explanation: Yes there are a few ways to style them including inline CSS, embedded CSS or an external style sheet. Basic coloring can be done with the fill and stroke attributes.
Example:
Basic coloring can be done by setting two attributes on the node: fill and stroke. fill sets the color inside the object and stroke sets the color of the line drawn around the object.
element. For a particular , as soon as it finds a , it knows that the matches and can stop its matching.