CSS inlineInline stylesThe simplest and most direct way of applying CSS to an element is to write it into the tag itself as a style attribute Inline CSS:<p style="border:2px solid #8dc919">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed enim. Morbi quis augue. Sed nec augue.
<p style="background:#8dc919">Sed vel pede eu lacus molestie condimentum. Pellentesque vitae dolor. Vestibulum venenatis. Output:Usage guidelines1. Use as little as possibleRemember that we're trying to separate content from presentation? Inline styles are the exact opposite. They're inefficient because they'll kludge up your code and are difficult to maintain. Only use them for some quick testing of CSS styles or for exceptions where a style is only used at a particular place and nowhere else on the homepage. 2. Don't use double quotesBecause double quotes are already used for marking the start and end of the style attribute, having another double quote in-between would abruptly terminate the CSS instructions. Use single quotes instead. |