Use existing CSS or create your own.. how to decide? [on hold]

86
April 25, 2018, at 08:48 AM

I jumped in the middle of a large project at work. I'm unsure when's the right time to try to find the a css style that is already in place that would work for my new elements I'm adding, or if I should just create my own styles, whether that's inline or added to the style sheet.

I'm just curious if there's a best practice in this regard, or if there's even a tool to help see if there is something close to what I'm looking for in the existing css.

EDIT: Well, to maybe avoid more downvotes, let me explain an example. I need to add a span with an with a link in it. That span needs to be float right and centered in the containing div. I sure could just add a rule to the style sheet, but I have NO IDEA how that will affect the other spans in other pages in the app. I mean, do most devs just add the rule to the style sheet, then go look through the entire site to make sure nothing else was adversely affected?

Answer 1

I suggest to reuse, if possible, existing classes and styles and write your own css in the existing stylesheets, not inline.

You can use Chrome for example to see what's going on with the HTML and css. Just use F12 to open the dev mode and see styles matching the selected element. Hope that helps.

READ ALSO
Styling Angular Component's Element from Main SCSS

Styling Angular Component's Element from Main SCSS

I'm struggling with something in my Angular 5x app, and hope someone can help

44
Make div same size as other images

Make div same size as other images

I have a website that im working on and there is a box with some links it itI want this box to be the same size as the images around it

88
Set Screen Reader text (and meta-information text) to a different value than visible text

Set Screen Reader text (and meta-information text) to a different value than visible text

I am dealing with a website where the author wants several key titles/headers to be in big ascii-artFor example, if a title said sandwitch, it would show up as:

50
How to define a font for Datalist elements?

How to define a font for Datalist elements?

What few sources I have found indicate that one cannot style datalist elements with CSS

78