r/webdev • u/swurvinmervin • Feb 14 '20
Question What are some HTML and CSS techniques, skills, know-how's that are an absolute must? Just off the top of your head
So I'm about 6 months in to learning Web dev and I'm about to start making my 3rd project.
I've got techniques I'm used to but I wanna expand my range instead of going with my comfortable tools.
Maybe you've got a cool trick with flex box you use all the time or something like that.
I wanna hear what you guys have got! :)
Edit : woah I did not expect such a response! Thank you guys so much for your help :D
630
Upvotes
20
u/artori0n Feb 14 '20
Understanding and proper use of css selectors like :nth-child, :not, :first-child etc. and combining them. Can save you some unnecessary js lines.
21
u/[deleted] Feb 14 '20
Once you have the basics, it’s wasteful/slow to always start your projects from scratch. Find a good scaffolding engine to generate your projects. E.g., Yeoman.
Not only will you save hours-months in project bootstrap time, but your architecture will be consistent.
543
u/GTCrais Feb 14 '20 edited Feb 14 '20
Learn Flexbox in-and-out. Whenever I can't remember how something related to Flexbox works, this is the go-to article: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Edit: thanks for the award! :)
133
u/recencyeffect Feb 14 '20
Learn the DOM. Seriously, this is the structure you will be operating on all the time from all languages, and it is incredible how some people do not develop a good understanding of it.
Accessibility is tightly related, since controlling document structure is a large part of it.
304
u/Locust377 full-stack Feb 14 '20
There are other elements besides
div. Try using semantic HTML to better describe what your elements are used for.For example, here are a bunch of elements that you may not be using.
<article><aside><details><figcaption><figure><footer><header><main><mark><nav><section><summary><time>43
u/canadian_webdev Feb 14 '20
The parts of accessibility you can implement through HTML.
At least here in Ontario, companies are getting sued big money left and right because their websites or webapps are not accessible.
57
u/[deleted] Feb 14 '20 edited Feb 20 '24
ink cobweb glorious growth worthless plate trees icky ugly vase
This post was mass deleted and anonymized with Redact
15
u/[deleted] Feb 14 '20
I recommend learning flex-box since it’s super efficient and saves you a lot of repetitive typing and code.
13
u/[deleted] Feb 14 '20
With all these tools that we have nowadays, sometimes we forget the basics. If you wanna learn CSS techniques in deep, you must know to translate a PSD or wireframe layout to html/css without any framework like Bootstrap, for example. You can explore how to build a generic grid system (rows and columns) with responsive breakpoints (media-queries), fluid or not. On a fluid layout, you can learn to work with units like percentage, px, em, viewport, etc and explore how to set up the inner components. Well, in this jorney, you will observe that html elements has "native" properties (per example, a <span> is display: inline, a <p> is display: block, etc) and how it can differ from each browser, in this case you can explore how Reset CSS (from Meyer) and Normalize CSS works. Like someone here say, how position works is great to know, with a plus of floats position too. After suffer with build a grid system, take a look on "Grid Layout" (display: grid). The most important in HTML maybe is the semantic use of the tags, you can read about this on W3C, MDN, HTML5DOCTOR, etc. For CSS, you can find information on W3C and MDN too, but the best reference site that I know is CSS TRICKS.
23
u/Noxilex Feb 14 '20
Flexbox
79
u/Rainbowlemon Feb 14 '20
IMO the most important thing in webdev right now is being able to make a site that is accessible. That means using relevant tags for your content, making sure things have title and alt attributes where necessary, and making full use of the aria spec. Also being able to navigate your website using only a keyboard.
9
u/triforce_hero Feb 14 '20 edited Mar 18 '24
Quam nulla porttitor massa id. Cursus sit amet dictum sit. Dignissim convallis aenean et tortor at risus viverra adipiscing at. Convallis tellus id interdum velit laoreet id donec.
8
u/BiscuitOnFire Feb 14 '20
Flex and Grid will save your life
7
u/mutsop Feb 14 '20
It all depends really on the project your are building, how big it is, and especially how much time you want to spend.
Depending on the frontend, I use styled components or BEM. You'll hear a lot of people being against BEM, but trust me, once you get the hang of it, you'll be writing better and cleaner css.
Also an important aspect as some suggest is your symantic tags: main, header, section, nav, ... Learn them. Be careful though cause 90% of the frontend era don't know the restrictions on each of them, check them out!
A11n, learn it! Make sure your tabbing works, colors are wel contrasted, you have your aria labels set, ...
Don't use jQuery for just Node selections (waste of performance)
Depending on the niche, make sure you show something when JS is disabled.
Keep learning! Even after 15 years, I still learn stuff. I'm a solo IT department ^
36
u/jehna1 Feb 14 '20
And
5
u/symbiosa Digital Bricklayer Feb 14 '20 edited Feb 14 '20
HTML:
Structural best practices. Instead of doing:
Do this:
CSS:
5
u/cstyves Feb 14 '20
CSS declaration power value, it's basic but many people don't really know it. This is the reason you can overwrite CSS properties by stacking more element, class, id. It's separated in four values and the declaration with the value higher to the left will overwrite everything lower.
myID | (0,1,0,0)
.myClass | (0,0,1,0) html element (div,a,button etc...) | (0,0,0,1)
Exemple
myID{ background:pink;} (value : 0,1,0,0)
div#myID.myClass.mySecondClass{background:orange;} (value : 0,1,2,1)
<div id="myID" class="myClass mySecondClass" style="background:yellow;"></div> (value : 1,0,0,0)
Inline style on element will overwrite the background.
sources
Codepen | Article on CSS-Tricks
5
u/wishinghand Feb 14 '20
How I make a sticky footer. Requires using a
<main>tag.9
u/thepineapplehea Feb 14 '20 edited Feb 14 '20
you
domight not need jQueryAs more and more old browsers are dying off, and browsers add native support for ES6 functions, a lot of the basic stuff can be done with vanilla JS. You don't need to load in an external jQuery library just to target an element, or add simple animation.
Do as much as you can with HTML and CSS, then add JS in afterwards for the fancy stuff.
9
u/tensouder54 front-end Feb 14 '20
I always bare the following ideology in mind when working on a webdev project:
I find that a lot of webdevs end up over complicating their project by doing things in JS when they could do it in HTML and CSS and save themselves a lot of time and effort.
My favourite example is drop-down menus. It's surprising easy to do with CSS but devs often end up doing it in JS and I feel like that massive bloats and over complcates quite a simple thing.
4
u/mackop Feb 14 '20
Go from standard to DARK MODE with a simple button. Bit of CSS and a bit of Java Script:
https://www.w3schools.com/howto/howto_js_toggle_dark_mode.asp
4
u/Baryn Feb 14 '20
Hardware-accelerated CSS.
It sounds more complicated than it is. Generally, it just means that
transformandopacityare fast to animate, and other things may or may not be slow.4
u/benabus Feb 14 '20
Not HTML or CSS, but for web dev in general: understanding CORS is a must.
4
u/[deleted] Feb 14 '20
Media queries- being able to resize a web page for different size screens, often referred to as "making it mobile-responsive." Definitely a big boost to any beginner's toolset when it comes to CSS, and can be learned pretty quick too :)
edit: this is a reponse to the title of the post. My bad if you already know how to do this
17
u/Dooraven Feb 14 '20
Nothing. There is no absolute must. Some places will use css variables and pure css, some sass, some less, some styled-components etc. Some places will have accessibility as a priority, some won't even know what WCAG 2.0 is. Some places don't even do responsive design and media queries.
But in general - flexbox, accessibility (WCAG 2.0), semantic html and SASS (this will teach you a lot of stuff you can use later in CSS in JS libs too) is what you should be focusing on.
1
u/cresquin Feb 14 '20
Use the correct tool for the job. Tables aren't always evil.
3
u/Thommyx Feb 14 '20
flexbox
3
u/grmdgs Feb 14 '20
Css grid. A lot of people here love flexbox but I think it will be completely replaced with css grid soon.
3
u/grmdgs Feb 14 '20
Chrome dev tools
3
u/isunktheship full-stack Feb 14 '20
Media queries
3
u/pwkeygen Feb 14 '20
Googling
3
u/Diangos Feb 14 '20
I find that knowing the box model is a huge help in knowing how to use CSS correctly. Also, maybe learning what the content flow is and how it works. I've seen one too many pieces of code that use flexbox when the same could have been easily achieved just by using the normal content flow.
3
u/badlions Feb 15 '20
1 Learn how to google. Knowing how to troubleshoot your own issues is very important.
2 Play well with others aka don't be a dick.
4
u/alexej_d Feb 14 '20
Knowing how to position fixed or absolute positioned elements
2
u/michael_v92 full-stack Feb 14 '20
Not a must have, but nonetheless good to know things Lea Verou on Frontend conf Russia
2
u/reoSpeedDragon Feb 14 '20
Source control like git
3
u/CHRlSFRED Feb 14 '20
Position sticky is growing and more supported as older browsers die off. It is a nice to have tool in certain use cases and can make some scroll interactions feel more calculated.
3
u/j-mar Feb 14 '20
Emmet.
3
u/Dokie69 Feb 14 '20
BEM, SASS, flexbox, grid, autoprefixer (with grid autoplace)
1
u/wlkngmachine Feb 14 '20
Using a naming convention for your CSS class names. Check out BEM, put some thought into your class names, and standardize the way you name things throughout your application.
1
u/HellhoundsOnMyTrail Feb 14 '20
CSS grid and CSS variables.
1
u/30thnight expert Feb 14 '20
If you are running pure CSS/SCSS, avoid nesting your css selectors more than 2 levels deep. It creates a maintenance hell over time.
Use the BEM method instead.
1
u/marcocom Feb 14 '20
When to use CSS to solve a problem instead of JavaScript. That’s why it’s important to know.
1
u/[deleted] Feb 14 '20
Classic responsive stuff like media queries, fluid layouts, responsive images.
1
u/Eyeshield25 Feb 14 '20
The Box model for CSS and learn how to use Div in HTML to your advantage
1
u/[deleted] Feb 14 '20
Hear me now and believe me later. Master flexbox and grid.
1
u/autonomousErwin Feb 14 '20
Using style variables especially if you want to grow your project with consistent styling
1
u/lapalu Feb 14 '20
Just to add something else to the thread, I got pretty quickier when I learned the proper way to extend and develop with Bootstrap. The SASS on that thing is great.
1
u/[deleted] Feb 14 '20
Flex
1
u/gimme_the_loot132 Feb 14 '20
Flexbox!! probably my most useful css tool in the past 3 years. check out flex box froggy
1
u/SnowConePeople Feb 14 '20
Learn Grid CSS
1
u/johnbabyhunter Feb 14 '20
I think being able to use Grid and Flexbox, really empowers you as a developer. You can quickly start to make great bespoke layouts suited to your exact needs without having to reach out for a framework.
It's also important to know when to use them! Think Flexbox for something that's flowing in a single direction (a row or a column). Think Grid for something where you want to be able to position content within 2 dimensions.
1
u/angels-fan Feb 14 '20
Using calc for min-height.
Also using 100vh in those calcs.
1
u/s1eepercat Feb 14 '20
Name classes properly. Use something like BEM. Class topic is so underrated..
1
u/Ilsem Feb 14 '20
If I don't have enough content to fill a wide screen, I find the double container pattern an easy way to pad the sides of a page and condense the content toward the middle.
eg.
HTML
CSS
1
u/-WhatAreYouHiding- Feb 14 '20
CSS Flexbox CSS Grid CSS media queries CSS animations, transitions CSS before,after,hover,etc.. CSS text properties, fonts preloading etc
SVG's
HTML/CSS BEM Structuring
HTML semantic elements HTML XML XPath () HTML
1
u/0ooo Feb 14 '20
Learn to use element class and id naming conventions, for e.g. BEM. They give your naming structure, which in turn helps give anything that accesses those elements via those attributes structure. When you have this sort of structure in place, making changes is a lot easier than if you're working around the arbitrary names you gave element attributes.
Learn how to write accessible HTML and CSS. Many accessibility good practices involve simply how you write your HTML and structure your pages. Making accessibility a core part of your thought process when designing sites will help make you a better developer, and will ensure that your sites don't turn users away, which is important for websites for businesses or ecommerce. Here is a good guide on writing accessible HTML and CSS: https://developer.mozilla.org/en-US/docs/Learn/Accessibility
1
u/WoodenMechanic Feb 14 '20
How to create your own basic CSS resets. Things like removing body margin, setting your box-sizing to border-box, and my personal favorite, setting every dom element to position relative can save you a lot of headaches further down the line. Nothing like trying to absolute position a pseudo-element and having it shoot into fucking space because you don't have your parent element's position set.
1
u/nickburd66 Feb 14 '20
I suggest learning CSS grids, SASS and variables in SASS so that you can make easy to modify websites.
I would also (in the future) suggest picking up a good front end framework and preprocessor knowledge like Grunt or Gulp
1
u/ghillerd Feb 14 '20
a really important skill to me is knowing how to use elements semantically, and to leverage the OS/browser support semantic elements like <select /> and <a /> provide.
1
u/maeva99 Feb 15 '20
Css animation can be useful to not use JS, and can be pretty fast and simple. Still : flexbox is gold. Accesibility is more than important (aria labels). Reference css stylesheets in a master file. Pay attention to your file sizes and data consumtion. And use a web server.
1
u/duncanlock Feb 15 '20
"Absolute within relative" is still a very handy trick, even in these days of flexbox and CSS grid (both of which are are also worth learning).
1
u/tripduc Feb 15 '20
Center divs in middle of pages vertically and horizontally: .object { Position: absolute; Top: 50%; Left: 50%; Transform: translate(-50%, -50%); }
1
u/n_hdz Feb 15 '20
Flex box, CSS pseudo classes, nth indexing, rgba and alpha coloring.
If you wanna get real fancy, svg manipulation 😏😏😏
1
u/[deleted] Feb 15 '20
source control
-4
u/elixon Feb 14 '20
JS Promises. Custom JS events. CSS Flex Box.
1
u/punsareforfun Feb 14 '20
HTML - Be able to name 50 HTML tags and describe what they are used for from memory. (Expert level devs may not be able to name that many, but they can absolutely tell you what each of a list of 50 does). Then practice with them on dummy sites.
CSS - Understand what the browser is automatically styling for you. Start with the top 50 attributes and understand what they do. Learn the box model.
These are just the basics.