Forum Moderators: not2easy

Message Too Old, No Replies

Can somebody in this forum help to optimize my css block?

Urgent! this is for my interview purpose. Thanks alot

         

garylee

6:29 pm on Jun 12, 2006 (gmt 0)

10+ Year Member



<style>

.myClass {
font-family:arial,verdana,sans-serif;
border-width:10px;
border-width-left:20px;
border-width-bottom:5px;
color:#ff6600;
font-weight:normal;
text-decoration:none;
font-size:1em;}

</style>

Little_G

6:39 pm on Jun 12, 2006 (gmt 0)

10+ Year Member



Hi,

Have a look at this:


.myClass {
font-family:arial,verdana,sans-serif;
border-width:10px 10px 5px 20px; /*You can shorthand this*/
color:#ff6600;
font-weight:normal; /*In theory you can remove this line because 'normal' is default*/
text-decoration:none; /*This is default as well*/
font-size:1em; /*As I understand it this is like setting the value to 100% of itself, pointless.*/
}

Border-width [w3.org]
CSS Lengths (mentions 'em') [w3.org]

Andrew

SuzyUK

6:54 pm on Jun 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hmmm we just love doing homework ;) hehe

joking aside, Welcome to WebmasterWorld garylee! :)

I(we?) would find it fairly impossible to optimise a single block of code like that because we have no idea what context the classname "myClass" might apply to

e.g. there would be no need to specify font-weight:normal unless you were using that class to override something like a <h1> which might be bold by default or something that had previously been declared as bold, then even if you did need to apply it yes all font delarations could be amalgamated into a font shorthand rule

then, usually text-decoration only need be applied to links, but it could be there to override something that has previously had a text decoration applied to it.. again not enough info

the border widths are the glaringly obvious problem, are they overriding something else that they have been written like that or is that the real test? (hint for free: what color or style are they)

and you might not get an "urgent" answer as "we are not your homework team" [webmasterworld.com], but every Welcome to you and I do hope you figure it out in time and get your job, [you should do for the innovative you ask the question (except for the "urgent" of course ;))]!

Suzy

encyclo

7:03 pm on Jun 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A couple more hints. ;) You can use
font:
to combine the different
font-family:
,
font-size:
and
font-weight:
declarations. You can also reduce the color definition to
#f60;
instead of the full six-digit color.

swa66

8:28 pm on Jun 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The answers are in the library. Look for the crash courses.