CSS - Defining Child Styles Inline
I have some CSS for forms as seen below. (depreciated version)
Code: <div class="item"> <div class="text">Your Name:</div> <div class="field"><input type="text" /></div> </div> ... form .text { float: left; width: 75px; } form .field { float: left; } Some forms I'd like to be wider than others, though. Is it possible to define the width of .text using inline styles (eg: <form style="*">) rather than create a new class for each width I want to use? Similar TutorialsHello. I'm trying to figure out a way to define link states (link, active, hover, visited) using an inline style or in a manner other than specifying via an imported or embedded style sheet. The project I'm working on involves designing an HTML email (template) with links that have formatting specified. Some webmail providers (particulalrly gmail and hotmail) seem to strip the away all code from the BODY tag on up (I assume to avoid conflicts with their own formatting), making formatting a very creative endeavor. Anyhow, without specifying these attributes in the header, is there any other way of doing this? The best I can figure out is specifying a link color, but without allowing for changes on visited, active, or hovered links. I've been googling for hours, so any help would be appreciated. Thanks. P.S. I know the prevailing attitudes on plain text vs html formatted emails and how it ties into spam, etc. I assure you this isn't being done in the context of spam, but rather, an opt-in newsletter for a client interested in sending fully formatted newsletters. :-) I've read up, and have always used a bit of CSS. I'm redoing my site, and noticed something different between Mozilla and IE. Personally, I'd ditch IE, but 98% of my viewers use it, so I can't. Basically, in IE, the following works: Code: P { color: black; font-size: 10pt; font-family:tahoma; } myown { color: blue; font-size: 10pt; font-family: Tahoma; } <myown>This is my text</myown> When I run it in IE though, it basically ignores the self-defined tag, and requires me to use a pre-defined keyword. I don't want to use "P", b/c it carries the html<P> tag characteristics... a new line in this case. Thanks. What is the difference between inline styles and id's? Are there places where you should use one and not the other? Sorry if this has already been answered but I couldn't find anything in a search. I need to create signature files for (Outlook) for my group. Until 2 days ago I knew nothing about css but I am learning. Coz Outlook only picks up the body from an html file I cannot use external css sheets, so all coding must be done inline. Only thing I can't figure out is the style for a weblink. Here's s snip of the relevant line: <a href="http://www.blabla.com.au" style="font: bold 8pt arial,sans-serif"> <span style="color:#ef812a; font-decoration: underline">www.blabla.com.au</span></a> The code (probably shabby) renders fine in Dreamweaver, but the sig in Outlook the underline shows blue - I want the underline for any link (visited, not visited) to show as #ef812a which is sort of orange. I can't figure out how to insert the a:link etc stuff. Thanks James Can you have both inline styles AND a linked style sheet? would this cause confusion? I'm basically asking the same question as this post, but hoping that I can press for a better solution. I have an element which contains an image and some text, and I need that element to expand to the width of the image, not the text. The size of the image will change, so I can't set a fixed width on the containing element. The code I have which doesn't work looks like this: Code: <html> <head> </head> <body> <span style="display: inline-block; border: 1px solid black"> <img src="someimage.jpg" style="width: 400px; height: 200px;" /> <div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam vel placerat sapien. Aenean tempus lorem justo, at eleifend mi. Nam elementum nisl ut elit blandit dapibus. Donec et massa turpis, ac tincidunt odio.</div> </span> </body> </html> The solution proposed in the post I linked to looks like this: Code: <html> <head> </head> <body> <table width="1"> <tr> <td> <img src="someimage.jpg" style="width: 400px; height: 200px;" /> </td> </tr> <tr> <td> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam vel placerat sapien. Aenean tempus lorem justo, at eleifend mi. Nam elementum nisl ut elit blandit dapibus. Donec et massa turpis, ac tincidunt odio. </td> </tr> </table> </body> </html> The second example gives me the functionality I'm looking for, but I would really like to avoid using tables. I'm hoping there is a CSS solution to this. Thanks. Just like the title says, the child is wider than the parent, and i want it automatically centered, so t hat the centers of both divs are inline with each other. I tried the Code: margin 0px auto; which works if the child is smaller, but it doesn't seem to work in this case, any other ideas? Is it possible to define the size of a DIV, by distance to the edges? very simple. this may sound strange, but i figured css would be the easiest solution. i simply have one of 2 characters that will display in each TD of a table. either Y or N. is there anyway to specify the color of the background, or TD, depending on the character within? if its Y, make it red, and if its N, make it blue. that all. any ideas??? Hello I have defined the following rules for anchors: Code: a:link { color: green; text-decoration: none; text-transform: none; list-style-type: disc; font-family: Arial; font-size: 12px; } a:hover { color: blue; text-decoration: underline; text-transform: none; list-style-type: disc; font-family: Arial; font-size: 12px; } a:visited { color: orange; text-decoration: none; text-transform: none; list-style-type: disc; font-family: Arial; font-size: 12px; } a:active { color: red; text-decoration: none; text-transform: none; list-style-type: disc; font-family: Arial; font-size: 12px; } I have 2 links in the site: Code: <a href="1.html">1</a> <a href="javascript: void test();">Test</a> The first link obeys the rules defined above The second link doesn't obey the hover rule for some reason. My only guess is that triggering JavaScript code from links may cause this problem. I am testing this on IE6 On Mozilla and Opera both links work fine I would appreciate any help Need some help defining a border around my index page. It shows up and works fine in IE but when I switch to FF/Netsxcape the page border is short of the content. Here is my page: [Not an actual business...just a learning project] My Home Page Here is My CSS file: My CSS File Now I ran both my HTML and CSS through the W3C Validators and all comes back perfect. (I know there is some small "clean-up" issues in my code, but I don't think it's relevant to this border issue...Maybe it is?) Anywhooo, when this page is displayed in FF or Netscape the bottom 1/3 of page content runs below my border...but shows up fine in IE. If there is a better way, (than defining the whole <BODY> as a <DIV> element) please enlighten me! Thanks for helping me learn...(in advance) PWD how do you define the the color of a hyperlink before it has been clicked and after it has been clicked? Thanks. Hi to all, & this is my question: say I have a css class such as: .classA1 { color: RED; font-weight: bold; font-size: 11px } Now I want to define other classes, that vary only in the font color, while everything else remains unchanged, for example: .classA2 = { color: GREEN; rest same as A1 } .classA3 = { color: BLUE; rest same as A1 } .classA4 = { color: YELLOW; rest same as A1 } How do I go about it, so I avoid having to repeat every time the same attributes? I know there is a way of defining a main class & then the variations (like for elements - a - a:hover - a:visited etc..) but I'm not sure how you do this... Thanks a lot for your help, Luca Ok what i have been asked to do is set up a webpage with three divisions ( i think), in a column structure. Title at top then seperate divisions? for each of my books which will be getting added. Now the books should be contained as the book title, author, publisher etc with an image to the right of all this information. However the author, title and publisher have all different formats, the author should be bold, the title in italics etc etc. I am finding it difficult to know what tag to use to split up this information. Just now i have created a <div> section labelled book1 for the first book. How do you go about splitting up the txt within this division tag as i will be writing a CSS sheet to manipulate the author, title and publisher with all different formats. Thanks i have just finished making a site for a collective of illustrators I belong to, and now I'm hearing back that some people are having trouble with it. It's at www.illustratorselbow.com (I'm not allowed to post a url without spaces!) & i'm hoping people might be able to have a look at it & view the source and help me out. If you click on somebody's name, you see the thumbnails on the right and the image on the left. When you compress the window, the thumbnails jump about and shrink. I want to make it so this can't happen- I'd rather that the section with the main image in it compressed a bit, or would side-scroll. Any idea how to do this? I'm pretty new to CSS too so I don't really know how to fix this. It's just a drag because on computers with smaller screens/resolutions, the thumbnails look really messy. (Bear in mind that I have extremely basic knowledge of html/css/php, i hand code rather than use dreamweaver etc, and I've never used php or css before this site. I started using it because I keep hearing that frames are bad news nowadays, but it's been sooo much trouble with my limited abilities... alas) Unfortunately I am not very experienced and I am trying to edit some coding that has been done for me. The code is as follows <div title="[[TITLE]]" style='background-image: url ([bg]); padding: 5%; width:90%; height:100%; padding-left: 6%; padding-right: 6%; background-size: 100% 100%; '> Now what happens is the words I type in this box are beautifully laid out because of the padding... The images placed in the box should stretch border to border - but obviously don't because of the padding.... Can anyone please tell me what I can change to give my text padding but images with no padding? Thanks so much Hello -- new to this forum. My questions concerns a problem I've run into many times. I'm trying to be CSS-moral and use style sheets as much as possible, or a least place properties in the Header. But here's what I run into. Many times I find it necessary to have different properties for the same tag within the Body. Currently, I use CSS to create the Menu items at the top of each web page, an Unordered List, using the "li" tags. Ok, but I just discovered that by using a new CSS statement, I can use custom bullets in the Body's li tag: list-style-image : url(bullet.gif) . Cool!!! So, I went about making a little dog bone .gif and used it for my bullet graphic halfway down the page. Voila! It worked. Voila! I suddenly have dog bones in my menu (which I don't want !), which also use the li tag. I only know two workarounds. 1) is to go back to the BAD practice of using the taboo in-line style="images/dogbone.gif" in each li within the body and NOT put the statement in the Header style section or 2) at least try to use CSS in the header by making a class like li.bone { list-style-image : bone} and then repeat class="bone" for each li in the body, which is only slightly shorter than just putting in the style="xxx" in the first place. So, how do we handle using different style properties for the same tag within the body? Perplexed, Mike I'd like to seperate blocks of text with a horazontal rule. I'd like it to be dashed. So, I've come up with this: Quote: hr { border: none 0; border-top: 1px dashed #000; width:98%; height: 1px } However, although this works well in IE, it Firefox there is too much space between the HR and the text block under it. In other words, the text above the HR comes right up to the line, but the text under the line, there is a larger gap. Any way to close the gap? Any ideas? On the site I am starting, I am following the suckerfish style of using a ul/li menu. That works fine. A little position difference I have to figure out between IE and the real browsers but it does work. Problem I run into is when one of my pages includes a ul in the content. Using the css as is, that ul in content is displaying incorrectly. It should just go down the page but instead goes across the page. In the stylesheet, I tried making two li's, li.menu and li.info. That broke the menu but the content list worked. I tried adding .menu to various other components in the css but couldn't get both to work. I use php to include the code for the menu so I don't have to go to each page if I want to make a change. Could someone give me a hand on making two the two li's work from a style sheet so that both the menu and the content work on that page. Here are the pages. The web page: http://www.cacct.com/new/faq.php The stylesheet: http://www.cacct.com/new/css/sitestyle.css The menu code: http://www.cacct.com/new/php/menu.html This is the first page I built using other methods before changing to stylesheets: You can see what the content should look like. http://www.cacct.com/new/faq.html Thanks tk Hi, I have an issue where my css loads fine with Safari and Firefox. However, I have no styling when it comes to any versions of IE. I have listed the code below. Any help would be greatly appreciated. (There is a bit of php, but css is not loaded through it). Code: <?php require_once("php/includes/sitewide.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title></title> <?php keywords(); ?> <?php description(); ?> <link href="css/sitestyle.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="menu"> <ul> <li class="active"><a href="<?php echo $link1; ?>"><?php echo $namelink1; ?></a></li> <li><a href="<?php echo $link2; ?>"><?php echo $namelink2; ?></a></li> <li><a href="<?php echo $link3; ?>"><?php echo $namelink3; ?></a></li> <li><a href="<?php echo $link4; ?>"><?php echo $namelink4; ?></a></li> <li><a href="<?php echo $link5; ?>"><?php echo $namelink5; ?></a></li> <li><a href="<?php echo $link6; ?>"><?php echo $namelink6; ?></a></li> <li><a href="<?php echo $link7; ?>"><?php echo $namelink7; ?></a></li> </ul> </div> <!-- end #menu --> <div id="header"> <h1><a href="<?php echo $link1; ?>"><?php echo $site_title; ?></a></h1> <h2 style="color: #FFFFFF;"><?php echo $statement; ?></h2> </div> <!-- end #header --> <div id="page"> <div id="content"> <div class="post hr"> <h1>Welcome to <em>Site Title</em></h1> <img src="images/building_1.jpg" alt="" width="120" height="120" class="left" /> <p><strong>SiteTitle</strong>performs home inspections that exceed the standards of the American Society of Home Inspectors. After accompanying us during the inspection, reading the inspection report, the client will know more about the home they are planning to purchase and quite often will know more about the condition of the house than the seller!*</p> </div> <div class="post"> <h2>Home Inspections</h2> <p><strong>Home Inspections</strong> are a necessity for homebuyers in South Carolina when purchasing a new or existing Home.*Potential homebuyers MUST be knowledgeable and informed of any and all problems that may exist prior to closing. The challenge is to find a qualified home inspector with the experience and knowledge of performing a thorough and comprehensive inspection of the property that the buyer can trust and can rely on the accuracy of the inspection.</p> <h3>Join Us</h3> <p>Join the hundreds of satisfied clients who have retained us to help them with their real estate transactions.</p> <blockquote> <p><?php quotes(); ?> </p> </blockquote> </div> </div> <!-- end #content --> <div id="sidebar"> <div id="updates" class="orangebox"> <h2><?php echo $header1; ?></h2> <ul> <li><a href="<?php echo $inspectlink_1; ?>"><?php echo $inspectname_1; ?></a></li> <li><a href="<?php echo $inspectlink_2; ?>"><?php echo $inspectname_2; ?></a></li> <li><a href="<?php echo $inspectlink_3; ?>"><?php echo $inspectname_3; ?></a></li> <li><a href="<?php echo $inspectlink_4; ?>"><?php echo $inspectname_4; ?></a></li> <li><a href="<?php echo $inspectlink_5; ?>"><?php echo $inspectname_5; ?></a></li> <li><a href="<?php echo $inspectlink_6; ?>"><?php echo $inspectname_6; ?></a></li> <li><a href="<?php echo $inspectlink_7; ?>"><?php echo $inspectname_7; ?></a></li> </ul> <h2><?php echo $header2 ?></h2> <ul> <li><a href="<?php echo $categorylink_1; ?>"><?php echo $categoryname_1; ?></a></li> <li><a href="<?php echo $categorylink_2; ?>"><?php echo $categoryname_2; ?></a></li> <li><a href="<?php echo $categorylink_3; ?>"><?php echo $categoryname_3; ?></a></li> <li><a href="<?php echo $categorylink_4; ?>"><?php echo $categoryname_4; ?></a></li> <li><a href="<?php echo $categorylink_5; ?>"><?php echo $categoryname_5; ?></a></li> <li><a href="<?php echo $categorylink_6; ?>"><?php echo $categoryname_6; ?></a></li> <li><a href="<?php echo $categorylink_7; ?>"><?php echo $categoryname_7; ?></a></li> </ul> </div> </div> <!-- end #sidebar --> <div style="clear: both;"> </div> </div> <!-- end #page --> <div id="footer"> <p id="legal"><?php echo COPYRIGHT; ?></p> </div> <!-- end #footer --> <?php analytics(); ?> </body> </html> Here is the css. Code: @charset "utf-8"; * { margin: 0; padding: 0; } body { background: #FFFFFF url(../images/img01.gif) repeat-x; text-align: justify; font-family: Georgia, "Times New Roman", Times, serif; font-size: 12px; color: #666666; } h1, h2, h3 { color: #333333; } h1, h2 { margin-bottom: 20px; font-weight: normal; } h1 { font-size: 197%; } h2 { font-size: 152%; } h3 { font-size: 100%; } p, ul, ol { margin-bottom: 20px; line-height: 1.8em; } ul, ol { margin-left: 3em; } blockquote { padding-left: 3em; background: url(../images/img08.gif) no-repeat; font-style: italic; } a:link { color: #1953A7; } a:active { color: #ED5C0C; } a:visited { color: #666666; } a:hover { text-decoration: none; color: #067600; } img { border: none; } img.left { float: left; margin: 0 20px 10px 0; } /* Menu */ #menu { width: 770px; height: 65px; margin: 0 auto; border-right: 1px solid #EDEBD5; } #menu ul { margin: 0; padding: 0; list-style: none; } #menu li { display: inline; } #menu a { display: block; float: left; width: 109px; height: 45px; padding: 20px 0 0 0; border-left: 1px solid #EDEBD5; text-transform: lowercase; text-decoration: none; text-align: center; font-size: 144%; color: #BABABA; } #menu a:hover { background: #F7F7F4; } #menu .active a { background: #F49A24; color: #FFFFFF; } /* Header */ #header { width: 770px; height: 170px; margin: 0 auto; } #header h1 { float: left; width: 220px; height: 100px; margin: 0; padding: 70px 0 0 0; background: url(../images/header_left.jpg) no-repeat; text-align: center; font-size: 36px; } #header h2 { float: right; width: 530px; height: 86px; margin: 0; background: url(../images/header_right.jpg) no-repeat; padding: 84px 20px 0 0; text-align: right; } #header a { text-transform: lowercase; text-decoration: none; font-style: italic; font-weight: normal; color: #FFFFFF; } /* Page */ #page { width: 770px; margin: 0 auto; padding: 20px 0; } /* Content */ #content { float: left; width: 550px; padding-top: 10px; } #submitButton:hover { } .submitButton { border-width: 1px; padding: 5px; border-style: solid; margin: 5px; border-color: #000000; color: inherit; } .input { border-width: 1px; padding: 5px; border-style: solid; margin: 5px; border-color: #000000; color: inherit; } .inputSmaller { border-width: 1px; padding: 5px; border-style: solid; margin: 5px; border-color: #000000; color: inherit; } .post { margin-bottom: 20px; padding: 0 20px; } .hr { border-bottom: 1px solid #EDEBD5; } /* Sidebar */ #sidebar { float: right; width: 210px; padding: 5px; background: #EDEBD5; } #sidebar h2 { margin: 0; padding: 5px 15px; color: #FFFFFF; } #sidebar h3 { font-size: 85%; color: #FFFFFF; } #sidebar ul { margin: 0; padding: 15px; list-style: none; } #sidebar li { } #sidebar a { color: #FFFFFF; } .orangebox { background: url(../images/img05.gif) repeat-y; } .orangebox h2 { background: url(../images/img06.gif) repeat-y; } /* Footer */ #footer { clear: both; height: 100px; padding: 25px 0; background: #EDEBD5 url(../images/img04.gif) repeat-x; } #footer p { margin: 0; text-align: center; font-size: 77%; } #footer a { color: #666666; } |