Help using a linked css file in php


#1

Hello,
I just started learning php the other day, and am having a problem getting a print statement to display properly using a linked css file. This is the statement I have:

print("<input id='text2a' type='text' maxlength='3' value='0'>".$stock_row[num_in_stock]."</input>");

and this is the css file snippet:

#text2a { position: absolute; left: 223px; top: 184px; width: 20px; height: 10px; font-size: 70%; font-family: verdana; font-weight: 500; border-width: 1px; border-style: none }

The book I have makes no reference to css files at all, and I can’t find anything online that states what you need to do to get linked css files to work with php. Thanks for any help.


#2

CSS is to modify the presentation of HTML, it has little to do with PHP. Check out the tag reference for more information on including external CSS files in HTML.

Besides that, has no end tag, and can’t be used in the way you’re trying to use it.

W3Schools is a very handy website for starting HTML webmasters, and I presume it will fix your problem for you :wink:


#3

I think I worded my question poorly, what I really meant to say is that this print statement print("<input id='text2a' type='text' maxlength='3' value='0'>".$stock_row[num_in_stock]."</input>"); should be referencing the #text2a section of my css file to display on the web page properly. But for some reason it is not. The code above is in the section of the page, and is nested within php tags. Is there something that I am missing to make this statement work? Like an include statement in my css file, or a seperate css file with the link statement within php tags? I know the css file is linked properly as the rest of my page comes out perfectly. Also for XHTML I do have to close all tags or it will not validate properly. Thanks.


#4

Ah, you’re using XHTML. In that case tags that don’t have end tags are supposed to be constructed as follows:

<tag attribute="value" />

What you’re doing is this:

<tag attribute="value"></tag>

Again, please take a look at W3Schools, and the article on tags. It will show you what to use and how to implement what you’re trying to achieve. Hint: use the ‘value’ attribute.


#5

Thanks for the ‘value’ hint, that did the trick :D