• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

CSS Interview Questions Answers

Question - 61 : - Why is my external stylesheet not working ?

Answer - 61 : - There may be several different reasons behind that, but one very common mistake is to have an external stylesheet that contains HTML markup in some form. An external stylesheet must contain only CSS rules, and if required, correctly formed CSS comments; never include any HTML syntax, such as <style type="text/css">… CSS comments are defined as anything that is placed between /* (the comment start mark) and */ (the comment end mark). I.e. as follows… /* This text right here is a correct CSS comment */ CSS comments may span multiple lines in the stylesheet. Nesting of CSS comments is not allowed. Another reason for external stylesheets (and even embedded and inline stylerules) not to function as expected may be that you have tried to make use of some CSS-features that are not supported in the browser you are using. External stylesheets shall also be served from the www-server with a MIME-type of 'text/css' in its 'Content Type:' HTTP header. You may need to negotiate with your server admin to add this MIME type to your server if you are not able to configure the server yourself.

Question - 62 : - How do you show which page you're on (in a menu)?

Answer - 62 : - If PHP is not available to you, you could use the cascade. Put an id in your body tags and an id in each of your 'a' tags for the links. Let's say on page one you have this: CSS <body id="page1"> .... <a id="page1link" href="page1.htm">page one</a> ... </body> In your CSS, you can have something like this: CSS #page1 a#page1link { color:purple;

Question - 63 : - How do I move the list bullet to the left/right?

Answer - 63 : - CSS1 has no properties for setting margins or padding around the bullet of a list item and in most cases the position of the bullet is browser-dependent. This is especially true since most browsers disagreed on whether a bullet is found within the margin or padding of a list item. In CSS2, properties were introduced to provide greater control over the placement of bullets (which CSS2 calls a "marker") but these were not widely supported by mid-2001 browsers. Here is an example of changing a marker's placement: li:before {display: marker; marker-offset: 22px; content: url(triangle.jpg);} In this example, a graphic of a triangle is inserted before the content of the li element, set to be a marker (through display: marker;), and given an offset of 22 pixels. Depending on the margin size of the list item, there may not be room for the marker to appear next to the list item's content.

Question - 64 : - Why can @import be at the top only?

Answer - 64 : - A style sheet that is imported into another one has a lower ranking in the cascading order: the importing style sheet overrides the imported one. Programmers may recognize this as the same model as in Java, Modula, Object-Pascal, Oberon and other modular programming languages. However, there is a competing model, well-known to C programmers, where the imported material is not lower in rank, but is expanded in-place and becomes an integral part of the importing document. By allowing @import only at the top of the style sheet, people that think in terms of the second model (although in principle incorrect) will still get the expected results: as long as the @import is before any other overriding rules, the two models are equivalent. Btw. In all the modular languages import statements are only allowed at the top. In C, the #include can be put elsewhere, but in practice everybody always puts it at the top. So there may not be that much need to allow @import elsewhere in the style sheet either.

Question - 65 : - As a reader, how can I make my browser recognize my own style sheet?

Answer - 65 : - Netscape It is not possible to do this in Netscape yet (as of version 4.0.) Internet Explorer 3.0 (Win95/NT) [It is possible to do this at least in Windows95/NT, but no user interface is provided. Unknown how this might be accomplished on other operating systems.] 1. Open the Registry editor (Start..Run..regedit..ENTER) 2. Under the 'HKEY_LOCAL_MACHINE\Software\Microsoft\InternetExplorer\Styles' key, Edit..New..String Value 3. The new value should be called 'StyleSheet Pathname' 4. For the value, type in the full directory path of your .css style sheet. Internet Explorer 4.0 (Win95/NT) 1. Under the View menu, select 'Internet Options'. 2. Under the 'General' tab, choose the 'Accessibility' button. 3. Choose the 'Format documents using my style sheet' check box and 'Browse...' to the location of your .css style sheet.

Question - 66 : - How do you make a whole div into a link?

Answer - 66 : - You can't put 'a' tags around a div, but you can do this with javascript : HTML <div onclick="javascript:location='http://bonrouge.com'" id="mydiv"> ... stuff goes here ... </div> If you want to use an empty div with a background image as a link instead of putting your image into the html, you can do something like this: CSS #empty { background-image:url(wine.jpg); width:50px; height:50px; margin:auto; } #empty a { display:block; height:50px; } * html #empty a { display:inline-block; } HTML <div id="empty"><a href="#n"></a></div>

Question - 67 : - Why was the decision made to make padding apply outside of the width of a 'box', rather than inside, which would seem to make more sense?

Answer - 67 : - It makes sense in some situations, but not in others. For example, when a child element is set to width: 100%, I don't think it should cover the padding of its parent. The box-sizing property in CSS3 addresses this issue. Ideally, the issue should have been addressed earlier, though.

Question - 68 : - How To Style Table Cells?

Answer - 68 : - Margin, Border and Padding are difficult to apply to inline elements. Officially, the <TD> tag is a block level element because it can contain other block level elements (see Basics - Elements). If you need to set special margins, borders, or padding inside a table cell, then use this markup: <td> yourtext </div></td> to apply the CSS rules to the div inside the cell. </p>

Question - 69 : - What is a Style Sheet?

Answer - 69 : - Style sheets are the way that standards-compliant Web designers define the layout, look-and-feel, and design of their pages. They are called Cascading Style Sheets or CSS. With style sheets, a designer can define many aspects of a Web page: * fonts * colors * layout * positioning * imagery * accessibility Style sheets give you a lot of power to define how your pages will look. And another great thing about them is that style sheets make it really easy to update your pages when you want to make a new design. Simply load in a new style sheet onto your pages and you're done.

Question - 70 : - Can CSS be used with other than HTML documents?

Answer - 70 : - Yes. CSS can be used with any ny structured document format. e.g. XML, however, the method of linking CSS with other document types has not been decided yet.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners