In html you don't have to mention px, but in css it does?

hi
im learning web development under an expert (my sir)

my sir said "
in html you don’t have to mention px, if u give its ur choice but in css it does
:vs:
when i asked chatgpt, it said “Not quite. Let me clarify:”
im confused now :frowning:

Welcome to the forum. :wave:

What is your question?

Maybe this will help you: https://www.w3schools.com/cssref/css_units.php

1 Like

who is correct my sir or chatgpt ? in terms of px (pixels) should i have to mention px in html or should i avoid it, ?

TLDR; No, use CSS.

You can read all about it here: https://www.freecodecamp.org/news/how-to-change-text-size-in-html/

Search engine > ChatGPT.

Welcome to the forum @amirbin.salam

You mentioned you are learning web development.

There are many approaches and learning pathways in web development.

In HTML, elements have default values, some have default pixel values.
So when learning HTML, you could ignore pixels if you are comfortable with default behaviour.

When you become more confident, you may want to create customised components for your web page.

Then CSS, especially external stylesheets, is something you may need to approach.

There are generally no right or wrong answers. Sometimes you may need to use the the inline style attribute for certain elements.

There maybe times when you use the style element.

For more complex webpages, or a website, external style sheets provide better code maintainability and makes it easier to scale.

Happy coding

1 Like