/    Sign up×
Community /Pin to ProfileBookmark

Same CSS code just in one line – how?

I have this code in my .css page:

[code]
ul#menu li#m_01 { margin-left: 35px; background-image: url(images/home.gif); width: 47px; }
html>body ul#menu li#m_01 { margin-left: 75px; }
[/code]

I want to transfer to the actual HTML page but I’m not sure how do I use the hack if I’m writing it in one line such as:

[code]
<li id=”m_01″><a href=”/home/”></li>
[code]

How can I do this?

to post a comment
CSS

7 Comments(s)

Copy linkTweet thisAlerts:
@OctoberWindSep 20.2007 — inline styles?
[code=html]
<ul>
<li style="margin-left: 75px; background-image: url(images/home.gif); width: 47px;">list item here</li>
</ul>
[/code]
Copy linkTweet thisAlerts:
@weeeauthorSep 20.2007 — That I do know - what do I do with the hack?
Copy linkTweet thisAlerts:
@WebnerdSep 20.2007 — Who is the hack for, IE?

_margin-left: 75px; should work as IE will read the underscore and other browsers will ignore
Copy linkTweet thisAlerts:
@weeeauthorSep 20.2007 — Thanks man! Yes, it's for IE.
Copy linkTweet thisAlerts:
@KravvitzSep 20.2007 — Why can't you just use a <style> element?

It's best to avoid using inline styles.

The underscore hack is not valid. Use it at your own risk.
Copy linkTweet thisAlerts:
@weeeauthorSep 20.2007 — Got it, Thanks Kravvitz!
Copy linkTweet thisAlerts:
@WebnerdSep 20.2007 — The underscore hack is not valid.[/quote]
Sure it's not valid but when it comes to IE, I do anything it takes to get that stupid browser to render things correctly ;-)
×

Success!

Help @weee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...