Kakeema
Kakeema

Reputation: 31

A question about different ways of writing things

Is there a specific reason as to why different ways of coding exists. Such as in website designing for a bold tag you can do the "b" tag or font-weight: bold in css. Does this exist just as an alternative way of doings this or is there a purpose as to why different ways exist?

Upvotes: 2

Views: 73

Answers (4)

Mohamad Fazel Hesari
Mohamad Fazel Hesari

Reputation: 116

your question is not that clear but my answer would be "there are tags in html that you should know, where to use them for example about bold fonts that you say, we have <strong> and <b tags for bolding texts, when we wanna emphasize on something that also matters in SEO in order to let google bots to understand we use strong tag"

Upvotes: 1

Oleg Gribanov
Oleg Gribanov

Reputation: 31

There are many different ways to write code that have developed historically. But you can find the best way by reading the W3C specifications. And always remember that to scale projects it is better to transfer properties to separate CSS files. That is, in a specific example, it is better not to use tag b at all, but you need to go to the cascading style file and write the properties of the bold font, because if you can have this property of this element written in many web pages, then you will have to run through all pages and look for this item to change it. And if you wrote this property for this element in the cascading style file, then you would be able to quickly fix the element's properties in the future, if necessary.

Upvotes: 0

Harry
Harry

Reputation: 326

I guess there still exists only one way! Checking on your example <b> is HTML's way of writing bold text and font-weight: bold is CSS's way of writing!

Upvotes: 1

Daemon Beast
Daemon Beast

Reputation: 2909

There are usually multiple ways of doing things because new ways were introduced and the old ways were kept for backwards compatibility to ensure old websites didn't break. Both ways are usually valid and have their own advantage; for example, the <b> tag in HTML allow you to easily make a word or sentence bold without having to write any CSS and the CSS style font-weight: bold allows you to style multiple elements with a specific class.

On a side note, avoid <b> and use <strong> instead, but only use <strong> when you want to emphasise the importance of text. Use CSS to make text bold if it has no significance.

Upvotes: 1

Related Questions