21 replies [Last post]
tripleshift
Offline
Enthusiast
Last seen: 13 years 6 weeks ago
Timezone: GMT+2
Joined: 2005-03-22
Posts: 70
Points: 0

hi there fellows,
I'm really stuck on this.

I always put my css in an external file, but this time I have to put ALL the css info inline 'cause the element I'm doing must be included in an always different page with its own style.

I've transferred all the css inline inside every tag but now I need to take care of links.

I searched all over and all I could find was this:

<a href="http://www.csscreator.com/" style="link, visited {color: #000000; text-decoration: none; } hover {text-decoration: none; color: #999999; }" >Css Creator</a>

I don't know if this is correct or not, but to me it doesn't work at all.

my question is.
is it possible to put the a:link, a:visited; a:hover, a:active inline inside a tag?

thanks in advance
tripleshift

...

I left my good sign in the other pants

antibland
antibland's picture
Offline
Leader
Pittsburgh
Last seen: 10 years 35 weeks ago
Pittsburgh
Joined: 2005-01-17
Posts: 603
Points: 0

how to put hover inline...

I've never seen what you're asking for. If you can't use an external file and must you inline, you may be forced to consider an easy (if not inconvenient) JavaScript solution. Just out of curiosity, why couldn't inpage CSS work for you (up top between <head></head>)?

Andrew

tripleshift
Offline
Enthusiast
Last seen: 13 years 6 weeks ago
Timezone: GMT+2
Joined: 2005-03-22
Posts: 70
Points: 0

how to put hover inline...

antibland wrote:
I've never seen what you're asking for.

huh.. what you mean exactly?

antibland wrote:
If you can't use an external file and must you inline, you may be forced to consider an easy (if not inconvenient) JavaScript solution.

eh eh Laughing out loud
no, I'm not going to use javascript

antibland wrote:
Just out of curiosity, why couldn't inpage CSS work for you (up top between <head></head>)?

Andrew

well the reason is my page is structured as follows:

<html>

<head>
<title></title>
</head>

<body>

	<div>
		CONTENT
	</div>

</body>
</html>

but the part I'm going to take is only the DIV with the content.

i'm creating this element contained in the div above and when its ready i'm going to pick it and put in a php page with a top and footer element included (containing their own css).

since the DIV i'm going to use in a php page doesn't have the html, head and body (because is going to be inserted in a page php generated which already has its own), I can't use a style inside head or external style.

I don't know if what I wrote is clear, ask if not.

to get back to the problem, I'm wondering how come is possible there's no way to put this elemant inline when EVERYTHING else can. Shock

thank you for your help anyway
tripleshift

...

I left my good sign in the other pants

Anonymous
Anonymous's picture
Guru

Re: how to put hover inline...

tripleshift wrote:
<a href="http://www.csscreator.com/" style="link, visited {color: #000000; text-decoration: none; } hover {text-decoration: none; color: #999999; }" >Css Creator</a>
First of all that's not even correct inline styling.

You are going to have to explain why an external style sheet won't work. Worst case scenario there will just be a billion different a.whatever's in your external sheet.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 35 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

how to put hover inline...

Tripleshift,
Without wishing to cause offence it would be a great help if you could perhaps think through your problem and re-post a clearer idea of what the exact problem is, There is undoubtedly a solution to your problem but it's difficult to make sense of it at the moment.

The code snippet in your first post is completely wrong and I'm afraid that you cannot inline pseudo elements they will have to go in the head or an external sheet.

Question: why can you not give your element a unique ID and style it from your external stylesheet?

Try and give us a clearer idea of how your using the php include and the general styling of the page that it will be inserted into, there will be a solution to your problem somewhere.

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

tripleshift
Offline
Enthusiast
Last seen: 13 years 6 weeks ago
Timezone: GMT+2
Joined: 2005-03-22
Posts: 70
Points: 0

how to put hover inline...

Triumph wrote:
tripleshift wrote:
<a href="http://www.csscreator.com/" style="link, visited {color: #000000; text-decoration: none; } hover {text-decoration: none; color: #999999; }" >Css Creator</a>
First of all that's not even correct inline styling.

I'm glad I finally know for sure it is wrong.
I stated in the first post I didn't know if it was correct or not, I just found it.

Triumph wrote:

You are going to have to explain why an external style sheet won't work. Worst case scenario there will just be a billion different a.whatever's in your external sheet.

I think I did it.
maybe I was not clear...
I'll explane better in the next post.
anyway I know there would be a billion different a.whatever's (not too many in this case though), but I HAVE to do this, I simply can't assign an external style sheet or define inside head.

tripleshift

...

I left my good sign in the other pants

Anonymous
Anonymous's picture
Guru

how to put hover inline...

tripleshift wrote:
I'll explane better in the next post.
anyway I know there would be a billion different a.whatever's (not too many in this case though), but I HAVE to do this, I simply can't assign an external style sheet or define inside head.
Then I await the explanation.

tripleshift
Offline
Enthusiast
Last seen: 13 years 6 weeks ago
Timezone: GMT+2
Joined: 2005-03-22
Posts: 70
Points: 0

how to put hover inline...

Hugo wrote:
Tripleshift,
Without wishing to cause offence ...

never think I would Wink
with me you can go straight and tell me I'm dumb Laughing out loud

Hugo wrote:
... it would be a great help if you could perhaps think through your problem and re-post a clearer idea of what the exact problem is,

yes, sorry.
what I was asking was:

is it possible (and how) to insert the

a:link		{color: #000000; text-decoration: none; }
a:visited	{color: #000000; text-decoration: none; }
a:hover		{color: #000000; text-decoration: none; }
a:active	{color: #000000; text-decoration: none; }

inline in a document for whatever the reason?
the answer seems to be no ...

Hugo wrote:
There is undoubtedly a solution to your problem but it's difficult to make sense of it at the moment.

The code snippet in your first post is completely wrong and I'm afraid that you cannot inline pseudo elements they will have to go in the head or an external sheet.

If I got you, you're saying what I'm triyng to do is impossible.
pseudo element CAN'T be inline.
ok, if this is true, I think I can stop tring to do it, and find another solution.

Hugo wrote:

Question: why can you not give your element a unique ID and style it from your external stylesheet?

Try and give us a clearer idea of how your using the php include and the general styling of the page that it will be inserted into, there will be a solution to your problem somewhere.

Hugo.

to help you understand better the include "issue", I am creating a poll layout for a php script.
the php script must be versatile to be fitted in ANY page thus it cannot refer to an external stylesheet, because I want it to be self operative without adding lines to an existing stylesheet or define an additional one in meta.

the file I'm working on is a simple html, but when the layout will be ready, I have to take only the part inside the body element and insert it with an include into another page which already has its own CSS.
this prevent me from adding the css into the head.
I can't use an external because I can't define the meta attrib for the same reason as above.

to conclude, you have to consider that the php script is going to be usable in ANY website, with its own stylesheet.

anyway don't mind about finding a solution (if you have one you're welcome anyway though) because if pseudo element cannot be inline, I have to find another solution.

if something is unclear please tell me, I'll try to explain better.

sorry for the double and long post.
tripleshift

...

I left my good sign in the other pants

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 1 hour 39 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9742
Points: 3821

how to put hover inline...

As Hugo suggested, give the elements in question an ID. You might call it #thatspecialelementthathasdifferentstylesoneverypage.

Since the styles will be PHP generated anyway, echo or print them in the head.

<html>
  <head>
    <? echo "<style type=\"text/cssstyle rules\">\n
             #thatlongid a:hover {\n
                 \tcolor: black;\n
                 \t}\n
             </style>" 
    ?>
  </head>
  <body>
    <? echo "<div id=\"thalingid\">\n
             \t<a href=\"some.html\">go</a>\n
             </div>
    ?>
If you know what styles belong on a page, then just embed them.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

tripleshift
Offline
Enthusiast
Last seen: 13 years 6 weeks ago
Timezone: GMT+2
Joined: 2005-03-22
Posts: 70
Points: 0

how to put hover inline...

kk5st wrote:
As Hugo suggested, give the elements in question an ID. You might call it #thatspecialelementthathasdifferentstylesoneverypage.

Since the styles will be PHP generated anyway, echo or print them in the head.
 
<html> 
  <head> 
    <? echo "<style type=\"text/cssstyle rules\">\n 
             #thatlongid a:hover {\n 
                 \tcolor: black;\n 
                 \t}\n 
             </style>"  
    ?> 
  </head> 
  <body> 
    <? echo "<div id=\"thalingid\">\n 
             \t<a href=\"some.html\">go</a>\n 
             </div> 
    ?>
If you know what styles belong on a page, then just embed them.

cheers,

gary


guys, I'm very sorry, maybe I can't explain myself...

the html that will be included in the php script must contain its own css inline because being only the content INSIDE the body, it doesn't have the <head>.

if this is a generic html file code:
 <html> 
 
<head> 
<title></title> 
</head> 
 
<body> 
 
   <div> 
      CONTENT 
   </div> 
 
</body> 
</html>

i have to put only the DIV in the php
 
... 
   <div> 
      CONTENT 
   </div> 
...

because the php file ALREADY has its own css.

this because the script must be usable by anybody in any page, this means no adding lines to the existing css.
the user of this script must be able to use it WITHOUT touching his own css or creating a new one or using mine or adding to HIS OWN page the style for the script.

I hope this time is clear. Smile

I appreciate the suggestion, but I really can't use a external css or the style call from within <head>, because the script is not intended to work on one single site, otherwise i could have included the css in the existent external.
it will be a public script, anybody must be able to put it in his own page without touching his own css.

All I needed to know, was if is possible to define pseudo element inline.
hugo pointed out is not possible, which I didn't know and that's why I was trying.
if anybody has an idea on how to define this pseudo inline (not external, not inside head) is very welcome, otherwise I really thank everybody who contributed to this discussion and I hope to be helpful one day.

bye
tripleshift

...

I left my good sign in the other pants

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 35 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

how to put hover inline...

Gary beat me to it, with his suggestion and was what I was thinking along the lines of ( although please don't give it the name Gary suggested Smile )

To try and understand this you seem to attempting to add some styling to a simple php include that will generate a block of html and you can't set it in the head as you can't rewrite to the head element of an unknown page likewise you can't place a call to an external sheet, I get the dilemma,

If someone has to place the include call in their page can you not maybe get them to place two lines, instead of 'include' use a function call say get_style() for the head and get_text() for the body insert and write the functions in a single php file ( apologies if that's confusing I'm working off the top of my head and am not the worlds greatest PHP exponent ) but there must be a way to achieve this, PHP is so versatile.

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

tripleshift
Offline
Enthusiast
Last seen: 13 years 6 weeks ago
Timezone: GMT+2
Joined: 2005-03-22
Posts: 70
Points: 0

how to put hover inline...

Hugo wrote:


...

To try and understand this you seem to attempting to add some styling to a simple php include that will generate a block of html and you can't set it in the head as you can't rewrite to the head element of an unknown page likewise you can't place a call to an external sheet, I get the dilemma,

Laughing out loud :D
this is it...

Hugo wrote:

If someone has to place the include call in their page can you not maybe get them to place two lines, instead of 'include' use a function call say get_style() for the head and get_text() for the body insert and write the functions in a single php file

yes, of course I thought to that solution...

Hugo wrote:

( apologies if that's confusing I'm working off the top of my head and am not the worlds greatest PHP exponent ) but there must be a way to achieve this, PHP is so versatile.

Hugo.


don't mind.
your solution is the first thing I thought, but we (I'm not alone) wanted not to have the user to insert that line for css.
I know is pretty easy for somebody who knows a bit, but I'm trying to make the script as much as easy as type a web address in the location bar.
you can't even imagine how many problems can have a totally inexperienced user.
even putting the simple include can be a problem.

anyway, I was just trying to get how to put the pseudo inline.
i'll find another way or simply take the hover out for now...
but the solution of a double include could be the next step once figured out it wouldn't be a big deal for the users.

bye and thanks
tripleshift

...

I left my good sign in the other pants

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 1 hour 39 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9742
Points: 3821

how to put hover inline...

:oops: ops! I missed the part about you not controlling the prime page.

It seems, then, that rather than an include, the object tag should be used to embed a complete html document. An example of the method is at "show/hide". The object is valid in html4 and xhtml1.0 strict where (i)frames are not.

Hugo: What's wrong with the name? I always try to use semantic labels for my elements. Smile

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

Anonymous
Anonymous's picture
Guru

how to put hover inline...

kk5st wrote:
Hugo: What's wrong with the name? I always try to use semantic labels for my elements. Smile

  <? echo "<style type=\"text/cssstyle rules\">\n
             #thatlongid a:hover {\n
                 \tcolor: black;\n
                 \t}\n
             </style>"
    ?>
  </head>
  <body>
    <? echo "<div id=\"thalingid\">\n

Laughing out loud

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 1 hour 39 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9742
Points: 3821

how to put hover inline...

I don't think Hugo was referring to my typos, but rather to "#thatspecialelementthathasdifferentstylesoneverypage".

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

Anonymous
Anonymous's picture
Guru

how to put hover inline...

kk5st wrote:
I don't think Hugo was referring to my typos, but rather to "#thatspecialelementthathasdifferentstylesoneverypage".
Laughing out loud Yeah, you forgot the underscores between each word. Wink

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 35 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

how to put hover inline...

Well it's just that you really should write it human readable;

#That_Special_Element_That_Has_Different_Styles_On_every_Page

If were going to be semantic lets be legible.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 1 hour 39 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9742
Points: 3821

how to put hover inline...

Yecch! There are two things regarding notation that I hate;

  1. underscores used as word separators, and
  2. camel notation.
I would be willing to use hyphens if pressed.

#that-special-element-that-has-different-styles-on-every-page

cheers,

gary

[/]

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

Anonymous
Anonymous's picture
Guru

how to put hover inline...

kk5st wrote:
Yecch! There are two things regarding notation that I hate;
  1. underscores used as word separators, and
  2. camel notation.
I would be willing to use hyphens if pressed.
What is "camel notation"? :oops:

[/]
Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 35 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

how to put hover inline...

I think Gary refers to the capitalization, my absolute pet hate in stylesheets or markup. my second being using underscores they're used in scripting syntax, hate seeing them in css or markup just confuses me mildly.

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 1 hour 39 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9742
Points: 3821

how to put hover inline...

Yeah, camel notation refers to the humped look of variables, methods, etc. that capitalize each word after the first.

document.getElementById()

It is also called Polish notation, but I don't know the reason. I'd hate to think it's the butt of a certain ethnic joke.Wink

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

tripleshift
Offline
Enthusiast
Last seen: 13 years 6 weeks ago
Timezone: GMT+2
Joined: 2005-03-22
Posts: 70
Points: 0

how to put hover inline...

At first I thought hugo meant gary forget to complete the id statement.

instead of:
#That_Special_Element_That_Has_Different_Styles_On_every_Page

it should have been:
#That_Special_Element_That_Has_Different_Styles_On_every_Page_And_Is_Cool_To_Do_Dont_Bother_To_Get_Why

\:D/

Laughing out loud :D Laughing out loud

finally I think I'll add a simple style="text-decoration: none; color: #000000;" for the (only) element that requires link properties.
at least unless the option of adding two includes instead of one becomes suitable.

bye
tripleshift

...

I left my good sign in the other pants