- This topic is empty.
-
AuthorPosts
-
July 3, 2014 at 6:38 am #174475
ravinder07
ParticipantHi, I was watching a video tutorial to make a responsive website from scratch in html5 and css3 on youtube : http://www.youtube.com/watch?v=eOG90Q8EfRo
In this video this guy use Body selector to style html body and also use body class to add style….since i am new i just want to know is there any point to use selector and class
body {
background-image: url(‘img/bg.png’);
color: #000305;
font-size: 87.5%; /* Base font size: 14px */
font-family: ‘Trebuchet MS’, Trebuchet, ‘Lucida Sans Unicode’, ‘Lucida Grande’, ‘Lucida Sans’, Arial, sans-serif;
line-height: 1.429;
margin: 0;
padding: 0;
text-align: left;
}.body {
clear: both;
margin: 0 auto; /* This guy use margin again*/__
width: 70%;
}Instead of this i am thinking to use it as
body { background-image: url('img/bg.png'); color: #000305; font-size: 87.5%; /* Base font size: 14px */ font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; line-height: 1.429; text-align: left; clear: both; width: 70%;
}
Hope i asked it properly and clearly.
Thank YouJuly 3, 2014 at 7:33 am #174479Paulie_D
MemberUnfortunately, I don’t have an hour to spend watching that video to find out why he does it…it may just be something he does.
I don’t see much point in clearing floats on the body either but _ <shrugs>_ whatever.
However, if you want to combine the properties into one declaration, it perfectly OK.
Personally I don’t limit the width of the
body
tag, I prefer a a wrapping div but it’s a matter of choice.July 3, 2014 at 8:16 am #174487Senff
ParticipantIt’s possible that he assigned a class to the body with a number of styles, to make it easy to remove all those styles at once (by removing the class, as opposed to removing each style one by one).
Though I admit the name “body” for the class is a bit dodgy.
July 3, 2014 at 8:34 am #174488ravinder07
Participantok you might be right but see in code. He used margin in Body selector and body class….why he use margin property two time….. check out my code i have bold margin used by him second time in body class. He already used margin in body selector. Is it a mistake or he did it for any purpose?
July 3, 2014 at 8:51 am #174492Senff
ParticipantBecause the styles on the body tag are the “default” styles, and the styles on the class that is assigned to the body are “overriding” styles that can change from time to time. Perhaps there are situations when the class doesn’t have a margin assigned to it — in that case, the default margin of 0 will be used.
July 3, 2014 at 9:04 am #174493ravinder07
Participantoh ok got it thanks…
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.