I have a question, I want to know if this is good practice or not

I took [display:block;cursor: pointer;] out of the lower 3 div styles and put them both in the first div style cause all 3 styles use the same code. Is this good practice, or do you not recommend doing that?

<div style="width:266px;display:block;cursor: pointer;" onclick="myObject=document.getElementById('myObj5h'); 
myObject.style.display='block'; this.style.display='none'">

<div style="width: 89px; height:24px; background-color:#00ffff; border-top-left-radius:50px;border-bottom-left-radius:50px;margin: 0px 0px 0 0px;">
</div>

<div style="width: 88px;height:24px;background-color:#ffffff;margin: -24px 0px 0 88px; ">
</div>

<div style="width: 89px; height:24px; background-color:#ff00ff; border-top-right-radius:50px;border-bottom-right-radius:50px; margin: -24px 0px 0 177px;">
</div>
</div>

We recommend NOT using inline styles at all - get rid of them and do the CSS properly as a separate file.

inline styles can’t respond to different screen sizes and convert the HTML into unmaintainable junk.

4 Likes

You didn’t answer my question. Maybe someone else will.

I did answer your question - both versions are the worst bad practice imaginable and you should stop asking which of two humongous piles of stinky junk in your kitchen is the better one for sitting in to eat you recipe book for lunch (although if you were asking that rather than about the actual junk you are asking about then it wouldn’t be anywhere near as bad),

I’ll wait for someone to answer my question thank you.

Did you read [color=red]this post[/color]? It was a reply to one of your older posts.

Your coding style:

  1. leaves a lot to be desired
  2. is bad practise
  3. can be simplified
  4. is difficult to edit
  5. is verbose
  6. prone to errors
  7. repetition causing large file size
  8. slow to load

Can anyone add anything that I have missed?

3 Likes

Would it have been good practice 20yrs ago?

We’re not coding 20 years ago

2 Likes

Not twenty years ago, not now and not ever.

Edit:
… here is a link to the very first web-page

Please right-click and view the source and especially notice that a linked style-sheet was used, Not a single inline style to be seen,
The style-sheet

3 Likes

Nowhere near that recent. Even the dinosaurs considered such coding to be worse than bad. Perhaps the amoeba back when life first began might have accepted it not having the brains to know any better.

5 Likes

First web-page was way back in 1965.

Youtube: The FIRST Web Page…

Did I mention that a linked style-sheet was used and not a single inline style statement?

1 Like

No one can just say, that’s fine, there’s nothing wrong with doing that, but there’s a better way to do it. That’s what I was looking for. But I guess no one knows how to say that.

In post# 6 there were 8 reasons stating problems with your code.

Is there anything you did not understand?

You don’t get it.

No, no one can say that because it simply isn’t true. How many different people in how many different ways have to tell you that it is junk do there have to be for you to hear!!! What is the point in you asking for advice and then telling everyone else they’re wrong?

1 Like

True because of a failing to answer questions.

I have to try and guess what you meant.

No, we can’t, because there is plenty wrong with it, which is what we’ve been endlessly trying to explain to you for the last fortnight.

To be clear:
No, that’s not fine, there’s nothing plenty wrong with doing that, but there’s a better way to do it.

Unfortunately, you’ve shown not the slightest interest in learning the right way to do anything, so I don’t see much point in wasting more of my time writing good code for you to ignore. From the general level of frustration indicated by others who are still bothering to read your threads (and I know many have given up), you might draw the conclusion that we all feel pretty much the same.

3 Likes

The codes I’m using, creating are going on blogger. That’s not really a good platform to be doing css.

I can’t be experimenting with all these outrageous codes. inline css is simple for me.

Good luck to you with that then.

1 Like