Technical interview questions and answers are crucial when preparing for a CSS Interview because companies expect candidates to understand selectors, box model, layouts, responsive design, animations, and modern styling techniques. CSS is one of the most important skills for frontend development, and interviews often include both theoretical and practical questions. Companies such as TCS, Wipro, Infosys, Cognizant, and Accenture frequently ask CSS questions to evaluate a candidate’s ability to structure and style web pages professionally. This guide includes the most commonly asked CSS interview questions with easy explanations, helping freshers, students, and job seekers build a strong foundation. Preparing these questions will boost your confidence for frontend developer roles, UI/UX interviews, and campus placements.
Web designers should strengthen their frontend expertise by mastering HTML markup and JavaScript interactivity for responsive design
1. What is CSS?
Answer: CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. Every element type as well as every occurrence of a specific element within that type can be declared an unique style, e.g. margins, positioning, color or size.
2. CSS is a web standard that describes style for XML/HTML documents.
3. CSS is a language that adds style (colors, images, borders, margins…) to your site.
Answer: A Cascading Style Sheet (CSS) is a list of statements (also known as rules) that can assign various rendering properties to HTML elements. Style rules can be specified for a single element occurrence, multiple elements, an entire document, or even multiple documents at once. It is possible to specify many different rules for an element in different locations using different methods. All these rules are collected and merged (known as a "cascading" of styles) when the document is rendered to form
Answer: External Style Sheet is a template/document/file containing style information which can be linked with any number of HTML documents. This is a very convenient way of formatting the entire site as well as restyling it by editing just one file. The file is linked with HTML documents via the LINK element inside the HEAD element. Files containing style information must have extension .css, e.g. style.css.
Answer: Style Sheets are templates, very similar to templates in desktop publishing applications, containing a collection of rules declared to various selectors (elements).
5. How do I have a background image that isn't tiled?
Answer: Specify the background-repeat property as no-repeat. You can also use the background property as a shortcut for specifying multiple background-* properties at once. Here's an example:
BODY {background: #FFF url(watermark.jpg) no-repeat;}
Answer: SGML (of which HTML is a derivative) was meant to be a device-independent method for conveying a document's structural and semantic content (its meaning.) It was never meant to convey physical formatting information. HTML has crossed this line and now contains many elements and attributes which specify visual style and formatting information. One of the main reasons for style sheets is to stop the creation of new HTML physical formatting constructs and once again separate style information from
Answer: Inline style is the style attached to one specific element. The style is specified directly in the start tag as a value of the STYLE attribute and will apply exclusively to this specific element occurrence.
Answer: To combine multiple/partial style sheets into one set the TITLE attribute taking one and the same value to the LINK element. The combined style will apply as a preferred style, e.g.:
9. Which set of definitions, HTML attributes or CSS properties, take precedence?
Answer: CSS properties take precedence over HTML attributes. If both are specified, HTML attributes will be displayed in browsers without CSS support but won't have any effect in browsers with CSS support.
10. How do I eliminate the blue border around linked images?
Answer: in your CSS, you can specify the border property for linked images:
a img { border: none ; }
However, note that removing the border that indicates an image is a link makes it harder for users to distinguish quickly and easily which images on a web page are clickable.
11. Why call the subtended angle a "pixel", instead of something else (e.g. "subangle")?
Answer: In most cases, a CSS pixel will be equal to a device pixel. But, as you point out, the definition of a CSS pixel will sometimes be different. For example, on a laser printer, one CSS pixel can be equal to 3x3 device pixels to avoid printing illegibly small text and images. I don't recall anyone ever proposing another name for it. Subangle? Personally, I think most people would prefer the pragmatic "px" to the non-intuitive "sa".
12. 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: 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.
13. Can CSS be used with other than HTML documents?
Answer: 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.
15. How do I design for backward compatibility using Style Sheets?
Answer: Existing HTML style methods (such as and ) may be easily combined with style sheet specification methods. Browsers that do not understand style sheets will use the older HTML formatting methods, and style sheets specifications can control the appearance of these elements in browsers that support CSS1.
Answer: Style sheets allow a much greater degree of layout and display control than has ever been possible thus far in HTML. The amount of format coding necessary to control display characteristics can be greatly reduced through the use of external style sheets which can be used by a group of documents. Also, multiple style sheets can be integrated from different sources to form a cohesive tapestry of styles for a document. Style sheets are also backward compatible - They can be mixed with HTML styling
Answer: There are two types of CSS rules: ruleset and at-rule. At-rule is a rule that applies to the whole style sheet and not to a specific selector only (like in ruleset). They all begin with the @ symbol followed by a keyword made up of letters a-z, A-Z, digits 0-9, dashes and escaped characters, e.g. @import or @font-face.
Answer: CSS selector is equivalent of HTML element(s). It is a string identifying to which element(s) the corresponding declaration(s) will apply and as such the link between the HTML document and the style sheet.
For example in P {text-indent: 10pt} the selector is P and is called type selector as it matches all instances of this element type in the document.
in P, UL {text-indent: 10pt} the selector is P and UL (see grouping); in .class {text-indent: 10pt} the selector is .class (see class selecto
Answer: CSS declaration is style attached to a specific selector. It consists of two parts; property which is equivalent of HTML attribute, e.g. text-indent: and value which is equivalent of HTML value, e.g. 10pt. NOTE: properties are always ended with a colon.
Answer: Cascade is a method of defining the weight (importance) of individual styling rules thus allowing conflicting rules to be sorted out should such rules apply to the same selector.
Declarations with increased weight take precedence over declaration with normal weight:
P {color: white ! important} /* increased weight */
P (color: black} /* normal weight */
Answer: No. Style sheets are case insensitive. Whatever is case insensitive in HTML is also case insensitive in CSS. However, parts that are not under control of CSS like font family names and URLs can be case sensitive - IMAGE.gif and image.gif is not the same file.
22. How do I have a non-tiling (non-repeating) background image?
Answer: With CSS, you can use the background-repeat property. The background repeat can be included in the shorthand background property, as in this example:
body {
background: white url(example.gif) no-repeat ;
color: black ;
}
23. CSS is clearly very useful for separating style from content. But apparently people tend to have problems when using it for layouts. Would you say this is because people have not yet understood how to properly do layout in CSS, or is it CSS that is lacking in this area? What can be done to improve the situation? --- Would the web benefit from HTML and CSS being complemented with some kind of "layout language"?
Answer: Layout and style should be tackled by the same language and the two are intertwined. Trying to split the two is like splitting the HTML specification in two, one specification describing inline elements and the other describing block elements. It's not worth the effort. CSS is capable of describing beautiful and scalable layouts. The CSS Zen Garden has been a eye-opening showcase of what is possible today. If MS IE had supported CSS tables, another set of layouts would have been possible. So, th
Answer: Property is a stylistic parameter (attribute) that can be influenced through CSS, e.g. FONT or WIDTH. There must always be a corresponing value or values set to each property, e.g. font: bold or font: bold san-serif.
25. What can be done with style sheets that can not be accomplished with regular HTML?
Answer: Many of the recent extensions to HTML have been tentative and somewhat crude attempts to control document layout. Style sheets go several steps beyond, and introduces complex border, margin and spacing control to most HTML elements. It also extends the capabilities introduced by most of the existing HTML browser extensions. Background colors or images can now be assigned to ANY HTML element instead of just the BODY element and borders can now be applied to any element instead of just to tables.
26. How do I write my style sheet so that it gracefully cascades with user's personal sheet ?
Answer: You can help with this by setting properties in recommended places. Style rules that apply to the whole document should be set in the BODY element -- and only there. In this way, the user can easily modify document-wide style settings
27. Is there anything that CAN'T be replaced by Style Sheets?
Answer: Quite a bit actually. Style sheets only specify information that controls display and rendering information. Virtual style elements that convey the NATURE of the content can not be replaced by style sheets, and hyperlinking and multimedia object insertion is not a part of style sheet functionality at all (although controlling how those objects appear IS part of style sheets functionality.) The CSS1 specification has gone out of its way to absorb ALL of the HTML functionality used in controlling
Answer: Yes. Comments can be written anywhere where whitespace is allowed and are treated as white space themselves. Anything written between /* and */ is treated as a comment (white space). NOTE: Comments cannot be nested.
Answer: The CSS-names; names of selectors, classes and IDs can contain characters a-z, A-Z, digits 0-9, period, hyphen, escaped characters, Unicode characters 161-255, as well as any Unicode character as a numeric code. The names cannot start with a dash or a digit. (Note: in HTML the value of the CLASS attribute can contain more characters).
Answer: Initial value is a default value of the property, that is the value given to the root element of the document tree. All properties have an initial value. If no specific value is set and/or if a property is not inherited the initial value is used. For example the background property is not inherited, however, the background of the parent element shines through because the initial value of background property is transparent.
31. How frustrating is it to write a specification knowing that you're at the browser vendors' mercy?
Answer: That's part of the game. I don't think any specification has a birthright to be fully supported by all browsers. There should be healthy competition between different specifications. I believe simple, author-friendly specifications will prevail in this environment.
Microformats are another way of developing new formats. Instead of having to convince browser vendors to support your favorite specification, microformats add semantics to HTML through the CLASS attribute. And style it with CSS.
32. How far can CSS be taken beyond the web page--that is, have generalized or non-web specific features for such things as page formatting or type setting?
Answer: Yes, it's possible to take CSS further in several directions. W3C just published a new Working Draft which describes features for printing, e.g., footnotes, cross-references, and even generated indexes.
Another great opportunity for CSS is Web Applications. Just like documents, applications need to be styled and CSS is an intrinsic component of AJAX. The "AJAX" name sounds great.
Answer: Forms and form elements like SELECT, INPUT etc. can be styled with CSS - partially.
Checkboxes and Radiobuttons do not yet accept styles, and Netscape 4.xx has certain issues, but here is a tutorial that explains the application of CSS Styles on Form Elements.
34. Can I attach more than one declaration to a selector?
Answer: Yes. If more than one declaration is attached to a selector they must appear in a semi colon separated list, e.g.;
Selector {declaration1; declaration2}
P {background: white; color: black}
35. What is the percentage value in 'font-size' relative to?
Answer: It is relative to the parent element's font-size. For example, if the style sheet says:
H1 {font-size: 20pt;}
SUP {font-size: 80%;}
...then a inside an
Answer: Generally no. However, values containing white spaces, e.g. font-family names should be quoted as whitespaces surrounding the font name are ignored and whitespaces inside the font name are converted to a single space, thus font names made up of more than one word (e.g.) 'Times New Roman' are interpreted as three different names: Times, New and Roman.
37. Do any WYSIWYG editors support the creation of Style Sheets? Any text-based HTML editors?
Answer: As support for CSS in browsers has matured in the last year, both WYSIWYG and Text-based HTML editors have appeared that allow the creation or the assistance of creating Cascading Style Sheet syntax. There are now at least two dozen editors supporting CSS syntax in some form. The W3C maintains an up-to-date list of these WYSIWYG and text-based editors.
Answer: Double or single quotes in URLs are optional. The tree following examples are equally valid:
BODY {background: url(pics/wave.png) blue}
BODY {background: url("pics/wave.png") blue}
BODY {background: url('pics/wave.png') blue}
39. Document Style Semantics and Specification Language (DSSSL)?
Answer: Document Style Semantics and Specification Language is an international standard, an expression language, a styling language for associating processing (formatting and transformation) with SGML documents, for example XML.
Answer: XSL is a proposed styling language for formatting XML (eXtensible Markup Language) documents. The proposal was submitted to the W3C by Microsoft, Inso, and ArborText.
Answer: Database Management system is a collection of programs that enables user to create and maintain a database.Thus a DBMS is a general purposed s/w system that facilitates the process of defining constructing and manipulating a database for various applications. (Defining a data base involves specifying the data types, structures and constraints for the data to be stored in the data database.Constructing a data base is the process of storing data itself on some storage medium that is controlled by
Answer: A catalog is a table that contain the information such as structure of each file ,the type and storage format of each data item and various constraints on the data .The information stored in the catalog is called Metadata . Whenever a request is made to access a particular data, the DBMS s/w refers to the catalog to determine the structure of the file.
Answer: Data warehousing and OLAP (online analytical processing ) systems are the techniques used in many companies to extract and analyze useful information from very large databases for decision making .
Answer: Unlike in the traditional file sys. the structure of the data files is stored in the DBMS catalog separately from the access programs . This property is called program-data independence.i.e. We neednt to change the code of the DBMS if the structure of the data is changed .Which is not supported by traditional file sys .
Answer: Object oriented RDBMS is a relational DBMS in which every thing is treated as objects. User can define operations on data as a part of the database definition.
Answer: An operation is specified in two parts .
1. Interface (operation name and data types of its arguments).
2. Implementation (the code part)
The implementation part can be changed without affecting the interface. This is called
program-operation independence.
Answer: Online transaction processing is an application that involve multiple database accesses from different parts of the world . OLTP needs a multi-user DBMS s/w to ensure that concurrent transactions operate correctly.
Answer: A database administrator is a person or a group responsible for authorizing access to the database, for coordinating and monitoring its use, and for acquiring s/w and h/w resources as needed.
Answer: Data base designers are responsible for identifying the data to be stored in the database and for choosing appropriate structure to represent and store this data .
Answer: 1. High initial investments in h/w, s/w, and training.
2. Generality that a DBMS provides for defining and processing data.
3. Overhead for providing security, concurrency control, recovery, and integrity functions.
Answer: It is a collection of concepts that can be used to describe the structure of a database. It provides necessary means to achieve this bstraction. By structure of a database we mean the data types, relations, and constraints that should hold on the data.
Answer: 1. High-level or conceptual data models.
2. Representational data models.
3. Low-level or physical data models.
High level data models provide the concepts that are close to the way many users perceive data.
Representational data models are provide concepts that provide the concepts that may be understood by end users but that are not too far removed from organization of data in the database.
Physical data models describe the details of how data is stored in the computers.
Answer: The description of a data base is called the database schema , which is specified during database design and is not expected to change frequently . A displayed schema is called schema diagram .We call each object in the schema as schema construct.
Answer: Data independency is defined as the capacity to change the conceptual schema without having to change the schema at the next higher level. We can define two types of data independence:
1. Logical data independence.
2. Physical data independence.
LDI is the capacity to change the conceptual schema without having to change external schemas or application programs.
PDI is the capacity to change the internal schema without having to change conceptual (or external) schemas.
Answer: The participation constraint specifies whether the existence of an entity depends on its being related to another entity via the relationship type. This is of two types:
1. Total participation.
2. Partial participation.
Answer: The entity types that do not have key attributes of their own are called weak entity types.
Rests are called strong entity types .The entity that gives identity to a weak entity is called owner entity. And the relationship is called identifying relationship. A weak entity type always has a total participation constraint with respect to its identifying relationship.
Answer: This data model is based on real world that consists of basic objects called entities and of relationship among these objects. Entities are described in a database by a set of attributes.
Answer: It is the process of defining a set of subclasses of an entity type where each subclass contain all the attributes and relationships of the parent entity and may have additional attributes and relationships which are specific to itself.
76. What are constraints on generalization and specialization?
Answer: 1. disjoint ness constraints.
2. Completeness constraints.
Disjointness constraint specifies that the subclasses of the specialization must be disjoint .i.e. an entity can be a member of at most one of the subclasses of the specialization. The reverse of it is overlapping.
Completeness constraint is a participation constraint which may be
1. Total
2. Partial
Total specialization constraint tells that each entity in the super class must be a member of some subclass in the specialization. An
Answer: Aggregation is an abstraction concept for building composite objects from their component objects. The abstraction of association is used to associate objects from several independent classes.
Answer: Redundant array of inexpensive (or independent) disks. The main goal of raid technology is to even out the widely different rates of performance improvement of disks against those in memory and microprocessor. Raid technology employs the technique of data striping to achieve higher transfer rates.
Answer: This is a primary file organization technique that provides very fast access to records on certain search conditions. The search condition must be an equality condition on a single field, called hash field of the file.
1. Internal hashing
2. External hashing
3. Extendible hashing
4. Linear hashing
5. Partitioned hashing
81. What are different types of relational constraints?
Answer: 1. Domain constraints
2. Key constraints
3. Entity integrity constraints
4. Referential integrity constraints
Domain constraints specify that the value of each attribute must be an atomic value from the domain of the attributes.
Key constraints tell that no two tuples can have the same combination of values for all their attributes.
Entity integrity constraint states that no primary key value can be null.
Referential integrity constraints states that a tuple in one relation that refers to
82. What is difference between a super key, a key, a candidate key and a primary key?
Answer: A super key specifies a uniqueness constrain that no two distinct tuples in a state can have the same value for the super key. Every relation has at least one default super key.A key is a minimal super key or the subset of the super key which is obtained after removing redundancy. A relation schema may have more than one key .In this case each key is called a candidate key. One of the candidate key with minimum number of attributes is chosen as primary key.
Answer: A schedule S is serial if, for every transaction T participating in the schedule, all the operations of T is executed consecutively in the schedule, otherwise, the schedule is called non-serial schedule.
Answer: Two schedules S and S are said to be view equivalent if the following three conditions hold :
1. Both S and S contain same set of transactions with same operations in them.
2. If any read operation read(x) reads a value written by a write operation or the original value of x the same conditions must hold in the other schedule for the same read(x) operation.
3. If an operation write1(y) is the last operation to write the value of y in schedule S then the same operation must be the last opera
95. What are the various methods of controlling concurrency?
Answer: 1. Locking
2. Time stamp
Locking data item to prevent multiple transactions from accessing the item concurrently.
A time stamp is a unique identifier for each transaction, generated by the system.
Answer: A lock is a variable associated with a data item that describes the status of the item with respect to the possible operations that can be applied to it.
Answer: A binary lock can have two states or values:
1. locked (1)
2. unlocked(0)
If locked it cannot be accessed by any other operations, else can be.
Answer: All the locking operations must precede the first unlock operation in the transaction .It does have two phases:
1. expanding phase (Locks are issued)
2. Shrinking phase (Locks are released)
101. What are different types of two phase lockings (2pl)?
Answer: 1. Basic
2. Conservative
3. Strict
4. Rigorous
this is the basic technique of 2pl described above.
Conservative 2pl requires a transaction to lock all the items it accesses before the transaction begins its execution, by pre-declaring Its read-set and write-set.
Strict 2pl guarantees that a transaction doesnt release any of its exclusive locks until after it commits or aborts.
Rigorous guarantees that a transaction doesnt release any of its locks (including shared locks) until after it
Answer: Dead lock occurs when each transaction T in a set of two or more transactions is waiting for some item that is locked by some other transaction T in the set. Hence each transaction is in a waiting queue, waiting for one of the other transactions to release the lock on them.
Answer: Triggers are the PL/SQL blocks definining an action the database should take when some database related event occurs. Triggers may be used to supplement declarative referential integrity, to enforce complex business rules, or to audit changes to data.