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.
9 ответов
+ 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
+ 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 :)
+ 2
no problem @Ashish :)
0
where did you see color="red" ?
can you write all your tag ?
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>.
0
Thanks Arul!
0
Oh. These examples have helped me more than those of the lessons. Thanks Deddy!
0
@ashish your example <h1 color="red">... doesn't write this is red in red color
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.