0

Query about style attributes in HTML.

Hi everyone! I'm a total stranger to programming languages who wanted to know about interiors of web pages. So, I stumbled upon HTML and it began to interest me. I have done a decent progress till now, but suddenly this style attribute started to confuse me. In W3Schools, they teach us as follows - style="color:red;", but here in Solo Learn they teach us as - color="red;". But, none of them explain why they use it as such. There must be any difference right? I would appreciate if somebody helps me know it.

2nd Oct 2017, 6:00 AM
Ashish Shivram Poojary
Ashish Shivram Poojary - avatar
9 Réponses
+ 3
both are true. when you type color="red" it means you set the color by its own attribute. but if you type style="color:red" you set the css of the tag you wanna customize. I prefer to use "style" bcoz it simplify my code. e.g color="red" width="5px" height="5px" => style="color:red;width:5;height5;" hope it helps
2nd Oct 2017, 6:17 AM
Nurul Uhkrowi
Nurul Uhkrowi - avatar
+ 3
There are actually 3 different ways of styling: - Inline version: the styling is done right in the tag itself - Internal version: the styling is done under the <style></style> tag which is located under inside the head tag - External version: in a separate file The inline version will look sth like this: <h4 style="color:blue;">There is something here</h4> The internal version will look sth like this: <head> <style> h4{ color: blue; } </style> </head> The external version is like this (in a separate file): h4{ color: blue; } Hope this clears your confusion :)
2nd Oct 2017, 6:18 AM
Deddy Tandean
+ 2
no problem @Ashish :)
2nd Oct 2017, 6:26 AM
Deddy Tandean
0
where did you see color="red" ? can you write all your tag ?
2nd Oct 2017, 6:14 AM
MBZH31
MBZH31 - avatar
0
Hi MBZH31, you may look into the HTML lessons. You will find it there. In almost all the cases, they use color="red" or font-family=“verdana" for styling purposes. For example <h1 color="red"> This is red </h1>.
2nd Oct 2017, 6:22 AM
Ashish Shivram Poojary
Ashish Shivram Poojary - avatar
0
Thanks Arul!
2nd Oct 2017, 6:22 AM
Ashish Shivram Poojary
Ashish Shivram Poojary - avatar
0
Oh. These examples have helped me more than those of the lessons. Thanks Deddy!
2nd Oct 2017, 6:25 AM
Ashish Shivram Poojary
Ashish Shivram Poojary - avatar
0
@ashish your example <h1 color="red">... doesn't write this is red in red color
2nd Oct 2017, 6:30 AM
MBZH31
MBZH31 - avatar
0
So MBZH31, would it be the problem with the app I use as a notepad for HTML? I don't have a continuous access to a computer yet, so I am practicing it in android.
2nd Oct 2017, 6:34 AM
Ashish Shivram Poojary
Ashish Shivram Poojary - avatar